Firefox 3.5
var doc = document.implementation.createDocument("", "", null); div.innerHTML = html; doc.appendChild(div); var res = doc.evaluate("//p[@class='content']/span", div, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; // res is null
var isFF36up = false; if (navigator.userAgent) { var ffver = navigator.userAgent.match(/Firefox\/3\.(\d+)/); isFF36up = ffver && parseInt(ffver[1], 10) >= 6; } var nsResolver = { lookupNamespaceURI:function (prefix) { if (isFF36up && prefix == "ns") { return "http://www.w3.org/1999/xhtml"; } else { return ""; } } }; var doc = document.implementation.createDocument("", "", null); div.innerHTML = html; doc.appendChild(div); var res = doc.evaluate("//ns:p[@class='content']/ns:span", div, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;