I donโt know why you got this error, but you can change XPathResult.ANY_TYPE to XPathResult.STRING_TYPE and will work (tested in firefox 3.6).
Cm:
var xmlString = '<form><name>test</name></form>'; var doc = new DOMParser().parseFromString(xmlString,'text/xml'); var result = doc.evaluate('/form/name', doc, null, XPathResult.STRING_TYPE, null); alert(result.stringValue);
See jsfiddle .
DETAILS:
The 4th parameter of the evaluate method is an integer in which you indicate what result you need ( link ). There are many types , like integer, string, and any type. This method returns an XPathResult that has many properties.
You must map the property (numberValue, stringValue) to the property used in the evaluation.
I just don't understand why any type didn't work with string value .
Toopera
source share