Created
August 25, 2017 17:06
-
-
Save giftig/3a1d37d39c50be54c5923560fa706e54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
import codecs | |
import sys | |
from xml.dom import minidom | |
filename = '/dev/stdin' | |
if len(sys.argv) > 1: | |
filename = sys.argv[1] | |
formatted = minidom.parse(filename).toprettyxml(indent=' ') | |
# Remove blank lines and trailing whitespace | |
lines = [ | |
l.rstrip() for l in formatted.split('\n') if l.strip() | |
] | |
formatted = '\n'.join(lines) | |
print formatted.encode('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment