I'm trying to get the values from a span
that doesn't have a class, and I managed to get the value inside one, but I need to get them all at once.
This is my code:
<span>one</span>
<span>two</span>
<span>three</span>
<span>four</span>
var headings = document.evaluate("//span[contains(., 'one')]", document, null, XPathResult.ANY_TYPE,
null );
var thisHeading = headings.iterateNext();
console.log(thisHeading); // Prints the html element in console
console.log(thisHeading.textContent);
How can it put several values in the document.evaluate()
, so I can print all the values?