vendredi 23 octobre 2015

XPath expression with if condition statement

I have an XML like the one below, but this is only a part of a bigger file.

example 1

<EFACT_D96A_INVOIC>
  <NADLoop1>
    <NAD NAD09="SE" NAD08="111 11" NAD07="" NAD06="CITY" NAD01="DP">
      <C082 C08203="9" C08202="" C08201="7350015610088"/>
      <C058 C05801="TESTNAME"/>
      <C080 C08001=""/>
      <C059 C05901="TESTSTREET 35"/>
    </NAD>
  </NADLoop1>
</EFACT_D96A_INVOIC>

example 2

<EFACT_D96A_INVOIC>
  <NADLoop1>
    <NAD NAD09="SE" NAD08="111 11" NAD07="" NAD06="CITY" NAD01="DP">
      <C082 C08203="9" C08202="" C08201="7350015610088"/>
      <C058 C05801=""/>
      <C080 C08001="TESTNAME"/>
      <C059 C05901="TESTSTREET 35"/>
    </NAD>
  </NADLoop1>
</EFACT_D96A_INVOIC>

I want to make an XPath expression that returns the value of either the attribute C05801 if not empty or C08001. Is that possible to do with a oneline XPath?

Aucun commentaire:

Enregistrer un commentaire