I have a xml structure like below
<?xml version="1.0" encoding="UTF-8"?>
<Result>
<node>
<field value="79055_v01" name="Id" />
</node>
<node>
<field value="79055" name="Id" />
</node>
<node>
<field value="79155" name="Id" />
</node>
<node>
<field value="811" name="Id" />
</node>
<node>
<field value="811_v16" name="Id" />
<field value="811" name="abc" />
</node>
</Result>
I want to select the which contain the field name 'Id' and the value '811'. What would be the xpath for this
So the correct xpath should return only
<node>
<field value="811" name="Id" />
</node>
Tried
/Result/node[field/@name='Id' and field/@value='811']
but this returns two nodes
If you want to get node that has field with two required attributes, try:
/Result/node[field[@name='Id' and @value='811']]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With