Wednesday, 12 October 2016

XML : XPath Expression for parent element

looked in some articles about this topic, but they all kind of differ to what I am trying to get.

My eaxmple 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:

  • Code type must be "own"
  • Code value must be AAA

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

No comments:

Post a Comment