Re: Keyboard Navigation Code - XPathEvaluate - need help
Martin Honnen <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | Liberty Development |
| Message-ID | <ctog8l$f351__10062.3932354667$1107281220$gmane$org@ripley.netscape.com> |
Ady Shimony wrote: > The problem is in this code that from some reason don't work under XUL > files. > > var path = '//a[@href] | //select | //button | //input[not(@type="hidden")] > | //textarea'; > > var resolver = doc.createNSResolver(doc.documentElement); > > var xpathResult = doc.evaluate(path, doc.documentElement, resolver, > XPathResult.ORDERED_NODE_ITERATOR_TYPE , null); > > XpathResult returns nothing under XUL files, return all elements in HTML > > What am I doing wrong here? How does the example XUL exactly look? XUL is XML and XUL elements are in the XUL namespace (and HTML elements in the XHTML namespace probably if HTML elements are used inside of XUL docs) so you likely need to make sure your resolver correctly resolves the namespaces and your XPath expression uses namespace prefixes even if the elements are in the default namespace (e.g. <window xmlns="...">) as XPath expression don't know about default namespaces meaning window as an XPath expression matches <window> elements (null namespace) but not <window xmlns="http://example.com/2005/02/ws"> for instance, for that you need to make sure you use a prefix in your XPath bound to the namespace URI e.g. if your resolver resolves 'ws' to 'http://example.com/2005/02/ws' then the XPath ws:window matches. -- Martin Honnen http://JavaScript.FAQTs.com/