Re: document.evaluate

Jonas Sicking <[email protected]> Thu, 14 Dec 2006 12:35:45 -0800
Newsgroups gmane.comp.mozilla.devel.xml
Message-ID <[email protected]>
Leon Bezuidenhout wrote:
> I have a page with a couple of XML islands. I call the following code to 
> return a specific node in one of the XML islands
>     document.evaluate(cXPathString, xNode, oNSResolver, 
> XPathResult.FIRST_ORDERED_NODE_TYPE, null);
> where xNode is a reference to the XML island I want to query. However, my 
> result is always in context of the first XML island on the form
> 
> Is this a bug or am I doing something wrong?

The issue is probably with the "XML island" rather than the XPath query. 
Firefox does not support XML islands in HTML pages, the whole page will 
be parsed using HTML parsing rules which may not produce the result you 
want. Use the DOM-Inspector to verify that the DOM looks like what you 
expect.

Alternatively, the problem could be in your XPath query. Note that the 
contents in your "XML island" is part of the normal page, so if you 
evaluate an expression like "//foo" you'll get all foo elements in the 
entire document, not just in that "XML island". And since you're 
requesting just the first node that node would likely be in the first 
island.

Hard to know what else could be the problem without an actual testcase.

/ Jonas