Fork me on GitHub
FREE UK Companies Open Data FREE UK Companies Open Data Contact us Contact Us Twitter LinkedIn

XML pretty print tool

This XML pretty printer will output the XML with consistent indenting, based upon the logical nesting depth of the tags. Quoting characters are made consistent, and new lines are inserted between tags. It is designed for XML that contains no mixed content, and the behaviour is undefined on encountering mixed content.

Split attributes Sort attributes Comments on new lines Normalise whitespace Display as HTML

The split attributes option controls whether or not it will place each attribute of an element on a new line. This can be helpful if the output is sent to diff, such as in XML Differences.

The sort attributes option causes xmlpp to sort the attributes on each element in alphabetical order. This makes it more consistent, allowing for easy comparisons.

Comments on new lines does exactly what you would expect.

When enabled, Normalise whitespace will remove leading and trailing whitespace from text content. For example,

<Total> 45 </Total>

will become


If you select Display as HTML then, rather than returning the raw XML, it will embed it in <pre> tags, so that you can see the XML in your browser.

The source code to XML Pretty Printer is available here.