XPath Element/object Is Undefined When Using Document.evaluate
How can I fix the regular JavaScript code so it doesn't say 'undefined' and displays the value of the input field? The jQuery code works fine and displays the input field value co
Solution 1:
document.evaluate()
returns an XPathResult. You can retrieve the element like this:
var obj = document.evaluate('//html/body/form/div[4]/label/input', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if(obj != null) {
alert(obj.value);
}
Post a Comment for "XPath Element/object Is Undefined When Using Document.evaluate"