====>>>>> I've moved to http://shallowhacker.blogspot.com

Monday, December 29

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 :)

No comments:

gigajosh.blogspot.com has moved to http://shallowhacker.blogspot.com

Hi, I recently moved to http://hallowhacker.blogspot.com so please come and find me there if you want to see my latest posts :-)

HTC TYTN II internet price graph

HTC TYTN II internet price graph

tracker

eXTReMe Tracker