Page 1 of 1

count different child elements

Posted: Wed Aug 22, 2018 9:26 am
by mariomueller
Hi all,

I got a XML like

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<A>
<B1> </B1>
<B1> </B1>
<B2> </B2>
<B2> </B2>
<B3> </B3>
</A>
How can I count the sum of all <B1> and <B2> nodes?

count(count(/A/B1) and count(/A/B2)) --> 1 which is wrong
count(/A/B1 and /A/B2) --> 1 which is wrong

correct would be 4

Thanks
Regards
Mario

Re: count different child elements

Posted: Wed Aug 22, 2018 9:32 am
by Radu
Hi Mario,

Try this:

Code: Select all

count(/A/B1 | /A/B2)
using "|" you can concat two (or more) node sequences.

Regards,
Radu

Re: count different child elements

Posted: Wed Aug 22, 2018 9:33 am
by mariomueller
Got it:

count(/A/B1 | /A/B2)

Re: count different child elements

Posted: Thu Aug 23, 2018 6:40 am
by mariomueller
Hi Radu,

many thanks. As you can see I found the same solution 1 minute later :-)

Regards
Mario