How to inspect XML files in a terminal

Posted . Visible to the public.

You can use xmllint to pretty-print ugly XML files on your terminal. Just say:

xmllint --format file.xml

That will restructure containers nicely into individual sections with proper indentation.\
Note that it will automagically work on gzipped XML files!

To write pretty output to a new file, just use the -o switch (short for --output):

xmllint --format file.xml -o pretty_file.xml

See the xmllint man page Show archive.org snapshot for other useful switches and more information.

Arne Hartherz
Last edit
Keywords
xml.gz
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2013-07-04 09:17)