If i have some xml in the form

<root> <a>hello</a> <b> <bi>hiya</bi> <bii>hey</bii> </b> <c/> <d>hello again</d> </root>

how can I

a) count the nodes? i.e. a, b, bi, bii, c, d so 6
b) count the nodes that are non empty a, bi, bii, d so 4

?

i have tried

xmldata.query('count(/root/*)') ))

but that only counts the top level nodes and I have no idea where to start with the non empty nodes

any help will be very much appreciated