Re: Xpath query of XPathResult?
Axel Hecht <[email protected]> Fri, 02 Jun 2006 18:35:25 +0200
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Message-ID | <[email protected]> |
hairbo wrote: > Not sure if this is the best place for this question, so apologies if > it is not. > > I would like to be able to run an Xpath query on the results returned > by the XPathResult "evaluate" function. I have a shell of XML, like > this: > > <results>arbitrary results here</results> > > ...where the "arbitrary results" could be a string, or more XML, such > as: > > <results> > <person> > <firstname>John</firstname> > <lastname>Doe</lastname> > </person> > </results> > > If I run an Xpath query to get the contents of the "results" node, I > cannot then run another xpath query against those results. > > I suppose the question is this: is there any way to "reset" the > returned value of "results" from an "XpathResult" back to an > "XmlDocument", or something like it? > > The MSXML parser seems to have no difficulty running an xpath query on > a returned nodeset, so I'm struggling to see why this appears to be so > difficult in Mozilla's implementation. However, I'm fairly new to this > code, so perhaps I'm missing some basic principle here. > > Any help would be appreciated. > I don't see why you shouldn't be able to do that, other than that we don't take an XpathResult as argument to evaluate, but only dom nodes. So you had to make that extra step and iterate over the result, get the node, and then evaluate with that. Not sweet, but works. E4X allows you do to the thing you want directly, btw, but of course, that's gecko only for now. Axel