Mr Sorbose
Mr Sorbose

Reputation: 777

XPath lookup based on sibling value

I have been looking for information to do a look up to find the sibling item but cannot find what I need/understand.

XML

<country>
    <code>GB</code>
    <name>United Kingdom</name>
    <currencysymbol>£</currencysymbol>
</country>

Question

Is it possible to find the value of currencysymbol node by using the xpath following-sibling when the only value I have to play with is GB? I.e. I need to get following-sibling currencysymbol where code=GB.

Upvotes: 0

Views: 65

Answers (2)

Mark Veenstra
Mark Veenstra

Reputation: 4739

You can use XPath for this, see:

/country[code='GB']/currencysymbol

Upvotes: 2

Eero Helenius
Eero Helenius

Reputation: 2585

Try:

//code[. = 'GB']/following-sibling::currencysymbol

Upvotes: 1

Related Questions