Skip to content

Instantly share code, notes, and snippets.

@geekman
Created November 17, 2011 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekman/1372625 to your computer and use it in GitHub Desktop.
Save geekman/1372625 to your computer and use it in GitHub Desktop.
pretty-prints XML
#!/usr/bin/python
#
# pretty print xml
# modified from http://stackoverflow.com/questions/749796
#
import xml.dom.minidom
import codecs
import sys
argslen = len(sys.argv)
assert argslen >= 2
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
xml = xml.dom.minidom.parse(sys.argv[1])
print xml.toprettyxml()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment