21

Totally new to xpath.

I have xml:

<Values>
   <Value Value="a" CustomAtr="1" />
   <Value Value="b" CustomAtr="2" />
   <Value Value="c" CustomAtr="3" />
</Values>

To get value by index, i can use: string(/*/Value[1]/@CustomAtr)

Is it possible to get value by key? Hot to get CustomAtr value where Value="b" ?

Thank you

1 Answer 1

43

this should do the trick:

string(//Value[@Value='b']/@CustomAttr)
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.