Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do combine 2 xPath queries

Tags:

xpath

I am trying to get a list of all element nodes that have a child of <min value="1" /> and do not have a child of <mustSupport value="true" />.

Both of these 2 queries work separately,

//differential/element[child::min[@value='1'] ]

//differential/element[not (child::mustsupport)]

but produce no results when combined.

//differential/element[child::min[@value='1']  and not [child::mustsupport] ]
like image 818
DeanM Avatar asked Nov 19 '25 15:11

DeanM


1 Answers

Not sure if it's a typo, but you have [ ] instead of ( ) on your not.

Also, xpath is case sensitive.

Lastly, the child:: axis is not necessary (although it's fine if it makes it easier to understand).

Try this...

//differential/element[min[@value='1'] and not(mustSupport[@value='true'])]
like image 108
Daniel Haley Avatar answered Nov 22 '25 19:11

Daniel Haley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!