adding to your method
$xml(file,level1,level2,level3,N).childnode returns total childnodes for N = 0 or the Nth.
$xml(file,level1).treelength returns the "childnode deepness" so if level1 is formatted like this
it returns 3 because level 4 is the deepest nested node and is 3 levels down.
Im sure theres loads more cool properties we can think off.
It would be a really nice feature