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

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Sergejs
  • 2,540
  • 6
  • 32
  • 51

1 Answers1

43

this should do the trick:

string(//Value[@Value='b']/@CustomAttr)