With the following xml, I'm trying to return true or false depending on whether all <CrucialNumber> elements are empty or not:
<Invoice>
<Details>
<LIN1>
<Quantity>1</Quantity>
<Product>Test XML</Product>
<CrucialNumber/>
</LIN1>
<LIN1>
<Quantity>1</Quantity>
<Product>Test XML</Product>
<CrucialNumber/>
</LIN1>
<LIN1>
<Quantity>1</Quantity>
<Product>Test XML</Product>
<CrucialNumber>123456</CrucialNumber>
</LIN1>
</Details>
</Invoice>
The data-type of the CrucialNumber element is string.
So far, these are the xpath expressions I have tried:
string-length(//CrucialNumber/*) > 0;
not(//CrucialNumber/*[text()]);
./Details/LIN1[*]/CrucialNumber[1] = "";
not(.//CrucialNumber/node())
should do it, it will be true if and only if either (a) there are no CrucialNumber descendant elements at all, or (b) all the descendant CrucialNumber elements are empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With