Added child counts to allow easy pruning of empty nodes.
Tidied attributes that appear in JSON/XML output.