Curl and xmllint play nicely together

Chris Sedlmayr

05 May 2011

If you work a lot with XML API’s (writing or consuming), and have ever called one directly using curl to test/debug some output, you may find that the output isn’t very friendly, and for larger responses it’s almost unreadable.

By using curl and xmllint together you can have your response nicely formatted.

To do so, invoke curl, and parse the response through xmllint, giving xmllint the –format option and the - option which tells it to read from stdin

curl -sL "" | xmllint --format -

The curl options used here are -s to invoke silent mode, and -L so it follows redirects.

Read more about xmllint here or view the man pages directly if you have it installed.