Pretty-printing JSON and XML on Mac OSX
richardlog.com
richardlog.com
alias json="python -mjson.tool"
alias xml="xmllint --format -"
then pipe into them like so: echo '{"one": 1}' | json
echo "<one>1</one>" | xmlJSONView Chrome Extension: https://chrome.google.com/webstore/detail/chklaanhfefbnpoihc...
XML Tree Chrome Extension: https://chrome.google.com/webstore/detail/gbammbheopgpmaagmc...
And JSONlint.com to copy/paste JSON from wherever: http://jsonlint.com/
Also love that Chrome dev tools now pretty prints JSON returned from XHRs in the network response tab.
A neat set of tricks, hopefully they'll replace jsonlint.com in my brain, and soon :)
So if the incoming XML had an empty tag specified as <tag></tag> xmllint will turn it into <tag/>. If you're specifically looking for <tag></tag> for some reason, then that could trip you up.
Shouldn't matter 99% of the time though.
It's saved me countless hours debugging web services, be it JSON, XML, AMF, you name it. There's a free 30 day trial, and it runs on Mac OSX, Windows, and Linux.
There's definitely better tools out there if you're willing to install something - but these are great when you're in a pinch.
tidy -xml -q -i < in.xml | less
etc.