Pretty print XML with Java

I have the following XML document all, in a single line:

All I need is, to pretty print it with nice tabs and all. This is the code:

This would nicely format it as below:

However, please note that it fails if there are spaces within the tags.

The source can be found here: https://github.com/paawak/blog/tree/master/code/pretty-print-xml

Leave a Reply

Your email address will not be published. Required fields are marked *