Currently I am getting xpath with javascript with this function.
document.evaluate(xp, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
and it returns me a list of nodes.
from those nodes I also want to get xpath again.
I am trying to do this:
try {
var iterator = document.evaluate(xp, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var posts = "[";
try {
var thisNode = iterator.iterateNext();
while (thisNode) {
console.log(thisNode);
var date = document.evaluate(xp, thisNode, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent;
console.log(date);
thisNode = iterator.iterateNext();
}
}catch (e) { }} catch (error) { }
The problem here is:
document.evaluate function with each node returns me different elements. each node behaves same like document.
I mean I want to get the xpath from an element but it tries to get it from whole html although I get the node before with first document.evaluate function.