1
votes

I am trying to return xpath result based on a text in a element.

This is my current expression: //S:Body/ns:2hentArsrapporterResponse/return/child::*[text()='2016']

however its only returning the the one element: Element='2016

The expression should return all of the elements in the return node if the element contains text '2016'. Can someone please help me with the correct expression? enter image description here

1

1 Answers

1
votes

It might be easier here to just return all entire matching <return> nodes. Since you want all children tags anyway, having an extra wrapper tag on the outside presumably would not be a problem, and it would also give you a better way of keeping your output organized. Towards this end, we can just filter the <return> node directly:

//S:Body/ns:2hentArsrapporterResponse/return[antallVersjoner[text()='2016'] or ar[text()='2016'] or ...]

This solution obviously depends on listing out all possible children nodes which might match. If you have many child nodes, this approach might not be optimal.