I'd just use xml2json and then apply jq. Usually gets the job done. The benefit of that is that you only need to learn jq.
See this blog post I wrote a while ago for an example: http://jeroenjanssens.com/2013/09/19/seven-command-line-tool...
See this blog post I wrote a while ago for an example: http://jeroenjanssens.com/2013/09/19/seven-command-line-tool...
[ {"tag":"something", "attributes": { ... }, "nodes": [ ...] }, ... ]
with nodes being objects with one key to indicate if the node is a text node or an element, and if a text node then a value, and so on.