<item id=1>
<name>item1</name>
<price>30</price>
</item>
<item id=2>
<name>item2</name>
</item>
I need an xpath to select only items that DO NOT have price for .net.
<item id=1>
<name>item1</name>
<price>30</price>
</item>
<item id=2>
<name>item2</name>
</item>
I need an xpath to select only items that DO NOT have price for .net.
For your original question:
item[price]
will give you all item
elements that have a price
element child. This includes an empty <price/>
so if you want to avoid matching
<item>
<name>item3</name>
<price></price>
</item>
then you need one of the following
item[price/text()]
item[normalize-space(price)]
For the inverse, to select only item
elements that do not have a price
, you can use
item[not(price)]