Skip to content

Instantly share code, notes, and snippets.

@HashRaygoza
Created October 25, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HashRaygoza/76c5d1ae9d4bc3f808b6a99a1720d558 to your computer and use it in GitHub Desktop.
Save HashRaygoza/76c5d1ae9d4bc3f808b6a99a1720d558 to your computer and use it in GitHub Desktop.
// XPath nos permite seleccionar objetos via su ubicacion en la estructura del XML
XPath xPath = XPathFactory.newInstance().newXPath();
// La ruta del elemento que deseamos, para este omitir el prefijo cfdi:
String expresionTranslados = "/Comprobante/Impuestos/Traslados/Traslado";
// Obtenemos todos los nodos que empatan con la ruta que indicamos
NodeList nodeListTranslados = (NodeList) xPath.compile(expresionTranslados).evaluate(documento, XPathConstants.NODESET);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment