pretty_print xml

Imagine you received a huge xml file but without line breaks… It’s one long line… Then you were told to make use of one section of it…

I know how to view the xml structure by using the XML Notepad, but I will have problems to copy and paste certain parts of it out.

I tried to replace “>” with “>n” and it was a little better at first, but I would then have to manually insert the indentations… I was tempted to write a quick and dirty xml parser… then I was like, I don’t think I am the only one having this issue.

I did some searches and found that there is an easy way to pretty print the xml files. I am on win7 btw.

First install Notepad++. You can download it at their official site or use the portable version.

Then copy and paste your xml string into notepad++. Opening your file is fine too. It looks pretty good already, but you can make it even better.

Go to TextFX -> TextFX HTML Tidy -> Tidy: Reindent XML

You are done!

P.S. I found an online tool at: http://www.shell-tools.net/index.php?op=xml_format

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s