Hi all, I'm a bit of an XPath noob and I'd be much obliged if you'd point me in the right direction here.
I want to select the first <product> in the source that has the child node <name> = 'bread'
The expression below yields the correct naswer but I'm thinking there must be a better/more concise way of doing it:
/TOWN/SHOP/BASKET[PRODUCT/NAME='bread'][1]/PRODUCT[NAME='bread'][1]
<TOWN>
<SHOP>
<BASKET type="plastic">
<PRODUCT>
<NAME>bread</NAME>
<VAL>BROWN</VAL>
</PRODUCT>
<PRODUCT>
<NAME>bread</NAME>
<VAL>WHITE</VAL>
</PRODUCT>
</BASKET>
<BASKET type="metal">
<PRODUCT>
<NAME>pasta</NAME>
<VAL>MAC</VAL>
</PRODUCT>
<PRODUCT>
<NAME>bread</NAME>
<VAL>TOASTED</VAL>
</PRODUCT>
</BASKET>
</SHOP>
</TOWN>
Cheers