Adding formatting to an XML document

Sometimes, when I have to program a web service client I have to deal with unformatted XML files. For example, the next one:


This is not a bad thing, because it is sent that way to save traffic, but I’d rather see it in a human readable format. So I use the xmllint command, that reformat and reindent the input.

$ xmllint --format test.xml
<?xml version="1.0"?>

The indentation can be controlled by the environment variable XMLLINT_INDENT. The default value is two spaces.

pfortuny, n0str0m0, do not worry guys, those are not your passwords, are they? ;)

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*Required Fields