85
rated 0 times
[
86]
[
1]
/ answers: 1 / hits: 48913
/ 8 Years ago, wed, march 30, 2016, 12:00:00
I'm using the document.evaluate()
JavaScript method to get an element pointed to by an XPath expression:
var element = document.evaluate(
path,
document,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null
).singleNodeValue;
But how do I get a list of elements in case the XPath expression points to more than one element on the page?
I tried the following code, but it is not working:
var element = document.evaluate(
path,
document,
null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE,
null
);
More From » xpath