Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda