Formatting XML for easier reading with Tidy


I've been working on performance tuning a clients application which makes heavy use of XML and in order to get my head around the structure of the XML I wanted to have a browse through the XML data.

So I did a Charles capture of the data to have a look. Unfortunately the data was formatted in a single line with no line breaks and as it was just under 1MB it upset all my usual editors (Eclipse & Gedit) and made them become completely unresponsive.

After a bit of hunting I finally found the right tool for the job – HTML Tidy.

With the following command I was able to get the XML formatted nicely which made my editors play nice and made it a lot easier to get an understanding of the data in the XML packet.


tidy -xml -i input.xml > formatted.xml

This takes the input.xml and indents it nicely and saves it as formatted.xml.

Cheers,
Mark


This post was posted in , , by on