Reputation: 7466
I have a XML document opened in Chrome and I would like to test some XPath expressions. The XML document involves different namespaces. How do I define the prefix URIs?
For testing XPath expressions in Chrome I have used $x("...")
so far.
Upvotes: 7
Views: 1195
Reputation: 9295
If you searched for an element "description" anywhere inside the XML document, you could use the local-name() function. Example:
$x("//*[local-name()='description']")
Inspired by this answer on SO.
Upvotes: 3
Reputation: 5265
as taken from developer.mozilla's Introduction_to_using_XPath_in_JavaScript
Implementing a User Defined Namespace Resolver
function nsResolver(prefix) {
var ns = {
'xhtml' : 'http://www.w3.org/1999/xhtml',
'mathml': 'http://www.w3.org/1998/Math/MathML'
};
return ns[prefix] || null;
}
Upvotes: 2