Tuesday, January 20, 2009

Pretty Printing XML in Ubuntu on the command line

Ever wanted a quick and easy way to reformat xml so that it is more readable?

In ubuntu just do this.

sudo aptitude install xml-twig-tools

Then you have a nice little program called xml_pp with which you can easily format xml documents.

Use it like this.

xml_pp document.xml | less


mirod said...

xml_grep is pretty useful too, you should check it out ;--)

Anil Philip said...

anil@anil-HP-EliteBook-8440p:~$ sudo aptitude install xml-twig-tools
[sudo] password for anil:
sudo: aptitude: command not found

Daniel said...

Just used this Paul. Thanks!

greuze said...

@Anil, in latest versions of ubuntu, aptitude is not a command anymore, you can just use:

sudo apt-get install xml-twig-tools