Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
XPath get node from a node

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!