http://www.perlmonks.org?node_id=1066453


in reply to XML output formatting

The XML file-format cares nothing for spaces, and usually does not include them, just to save bytes.

As this O’Reilly article shows, XSLT can be used both to extract relevant parts of an XML document, and to pretty-print the extracted data.   No programming is required (except to the extent that XSLT is a form of programming ...).

If you are using LibXML, then all of these capabilities are at your beck and call.