Reputation: 43
Could you please clarify is it possible to extract the value of an attribute by requesting other attribute via XPath?
For Example:
<Attributes>
<Attribute>
<Id>5</Id>
<Value>56757364</Value>
</Attribute>
</Attributes>
<Attributes>
<Attribute>
<Id>6</Id>
<Value>23372670</Value>
</Attribute>
</Attributes>
I have to get '23372670'
by requesting Id = 6
.
And I can't use
//Attributes/Attribute[1]/Value
because my XML files contains many Attributes with different order of attributes.
Upvotes: 1
Views: 39
Reputation: 52665
This one should work:
/Attributes/Attribute[Id=6]/Value
or if you need to preserve Attribute
node structure
/Attributes/Attribute/Id[.=6]/following-sibling::Value
Upvotes: 1