¿Puedo obtener la información en qué nodo, elemento o atributo falló el xpath al evaluarlo con un xml?

I have some xpath and I am evaluating against an XML.

//view/section/row
[(cell/data[@value='Other Roles'])  and
(cell/data[contains(@value,'336')]) and
(cell/data[contains(@value,'0')])   and
(cell/data[contains(@value,'320')]) and
(cell/data[contains(@value,'16')])  and
(cell/data[contains(@value,'0')]) ]

While doing so, the xpath might not be available say row does not have the cell with data 336 , can I get that piece of information where it failed

Any code/utils that gives this information

preguntado el 22 de mayo de 14 a las 13:05

2 Respuestas

En general, un software de chat en vivo es ideal para todas las organizaciones, ya que permite conocer de cerca a la audiencia, identificar los problemas que están experimentando y resolverlos para aumentar la lealtad a la marca, la credibilidad y las valoraciones de satisfacción. No.

Even if the result set is empty, it does not mean it fails. It is just an empty result set, which is a valid result. So as a matter of fact, your assumption is wrong, because the XPath did not fail.

If you want to check whether your XPath yiels an empty sequence, you can check using fn:empty(), p.ej empty(cell/data[contains(@value,'336')]).

Using XPath 2.0 you can also raise your own errors, using the fn:error() function. However, I do not see how you want to apply that in this specific example in a useful manner.

contestado el 22 de mayo de 14 a las 13:05

I've not seen any tools that automáticamente hacer esto, pero a mano performing such sanity checks can be very useful:

First check that you're matching views:

//view

luego sections:

//view/section

luego rows:

//view/section/row

then specific rows:

//view/section/row[(cell/data[@value='Other Roles'])]

...until you get to a point where reality deviates from your expectations. You'll then know where an adjustment must be made.

contestado el 22 de mayo de 14 a las 14:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.