Test XPath expressions with namespaces in Chrome Test XPath expressions with namespaces in Chrome google-chrome google-chrome

Test XPath expressions with namespaces in Chrome


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;}


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.