It’s quite handy to indent XML when you need to read it with the human eye, but on a terminal it’s often not as easily readible.
Fortunatly there’s a command which’ll indent it so you can actually read it;
xmllint –format file.xml
This will show you how ugly it could be:
And behold the indented beauty of this little gem:
Note, if you don’t have xmllint installed on your system you’ll need to add the libxml2-utils package. (at least this is what provides it on debian systems)
Thanks for the tip Steven!
Is there a way i can get colored output?
Hi Mohit,
Not that i know of. The easiest way to get colored output is to copy the formatted XML to an editor and copy the colored output from there. For a couple of suggestions look for “colored xml formatting” on Google. (Also plenty of free options available)
Works great and very fast. Exactly what I was looking for. Thanks!