Reputation: 1465
looked in some articles about this topic, but they all kind of differ to what I am trying to get.
My example XML file:
<AdditionalInformations>
<AdditionalInformation>
<Codes>
<Code type="own">AAA</Code>
<Code type="foreign">ZZZ</Code>
</Codes>
<Value>MyValue</Value>
</AdditionalInformation>
<AdditionalInformation>
<Codes>
<Code type="foreign">BBB</Code>
</Codes>
<Value>2173.123</Value>
</AdditionalInformation>
<AdditionalInformation>
<Codes>
<Code type="own">CCC</Code>
</Codes>
<Value>true</Value>
</AdditionalInformation>
</AdditionalInformations>
Now I what the xPath to get "MyValue". The requirements are the following:
I tried this expression:
/AdditionalInformations/AdditionalInformation/[Codes/Code[@type="own"]="AAA"]
but I am not sure how to get to the value-element from there.
Thanks for your help Hauke
Upvotes: 0
Views: 162
Reputation: 185075
Try this xpath :
'//Codes/Code[@type="own" and text() = "AAA"]/../../Value/text()'
..
means parent node
Upvotes: 1