Re: Xpath query of XPathResult?

Martin Honnen <[email protected]> Mon, 05 Jun 2006 17:02:33 +0200
Newsgroups gmane.comp.mozilla.devel.xml
Organization Liberty Development
Message-ID <[email protected]>
hairbo wrote:

> As for Mozilla, I found a workaround that isn't too ugly.  I do the
> following:
> 
> var xmlString = new
> XMLSerializer().serializeToString(result.iterateNext());
> var xmlDoc = new DOMParser().parseFromString(xmlString, "text/xml");
> 
> The first line takes the result of the XpathResult ("result"), and
> serializes it to a string.  The next line takes that string of XML and
> converts it into an XmlDocument, which I can then re-query.

I am not sure I understand the need for that approach. The iterateNext 
function gives you a DOM node, if you want to make that DOM node the 
context node of another XPath evaluation then you can simply do
   var node = result.iterateNext();
   if (node != null) {
     var secondResult = node.ownerDocument.evaluate(
       'xpathexpression goes here',
       node,
       null,
       0,
       null
     );

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/