Tuesday, 10 February 2015

Determine if XML Element with specific value is present using XPATH



I googled the following but I don't get an aswer. Maybe my wording for this is not correct. I cannot believe that I am the only one who is trying to do this. Appologies if this is an easy question


I have an XML like this



<responseMessage>
<list>
<reason>RC1</reason>
<value>
<id>1</id>
</value>

</list>
<list>
<reason>RC2</reason>
<value>
<id>2</id>
</value>
</list>
<list>
<reason>RC3</reason>
<value>
<id>3</id>
</value>
</list>
<list>
<reason>RC4</reason>
<value>
<id>3</id>
</value>
</list>


What XPath expression can I use to test if a List Element is present with sub child where the id of a value is 3? The order of the list is undeterminend and can be the first List item now and the 2nd time it can be last


No comments:

Post a Comment