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?
What about this. You return both values (if they exists) and just take first one.
/EFACT_D96A_INVOIC/NADLoop1/NAD/*[@C05801!="" or @C08001!=""][1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.