How to format (prettify) XML

Today I used Eclipse with the XMLBuddy plugin to format (prettify) a chunk of XML.
I then tweaked it with TextPad... as follows.

1)
Get Eclipse at http://www.eclipse.org/downloads/. The IDE for Java developers will probably be fine for you. (It may seem like serious overkill for formatting a bit of XML, but that all depends on how badly you want to format that bit of XML now doesn't it? :))

2)
Get the XMLBuddy plugin: http://www.xmlbuddy.com/2.0/download.php

3)
You just need to unpack the XMLBuddy plugin ZIP file to the Eclipse "plugins" directory, but here are some XMLBuddy install tips in case you have problems: http://www.xmlbuddy.com/2.0/faq.html#install

4)
Then just open your XML file with Eclipse and choose "Format" from the "XML" menu.

5)
The only problem is that it uses tabs to indent the XML, which you may find a bit of a pain, so I then tweaked it in TextPad as follows:
Copy the XML you formatted in Eclipse into TextPad (or some other text editor with search&replace) and use F8 (find/replace) to swap the tabs for spaces, and you've got a decently formatted bit of XML!

Good luck :)

Comments

Popular posts (all time)

Unsync and Remove iPhone Contacts From Facebook

WhatsApp from your Phone & Computer at the same time (PC/Mac)

How I Fixed Mac OSX Lion NTFS issue

How to get an SSH server running on a Mac