I am trying to use figure out how xpath is working in FireFox, but I am unable to resolve a simple namespace prefix. The lookupNamespaceURI keeps on returning null.
I was unable to find any working examples on the net, so I am wondering if I am using this function correctly. Any insight would be very helpful.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<script type="text/javascript">
var testResolver = function()
{
var resolver = document.createNSResolver(document.documentElement);
alert(resolver.lookupNamespaceURI('ev'));
}
</script>
</head>
<body onload="testResolver()">
</body>
</html>
Make sure you serve the document with an XML or XHTML MIME type e.g.
Content-Type: application/xmlorContent-Type: application/xhtml+xml(example at http://home.arcor.de/martin.honnen/xml/test2011091101.xhtml). If you serve as text/html then I don’t think namespace resolution will work.