0

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

1 Answer 1

1

Something like

boolean(//list/value/id[text()='3'])

you mean? Here the boolean() function converts the result to true or false. An empty result is false and a result of one or more elements evaluates to true. Or even simpler:

//list/value/id/text()='3'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.