If i have some xml in the form

<d>hello again</d>

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