Last active
December 1, 2021 07:14
-
-
Save odashi/5ba522b51032203d2a0a36559ff1726f to your computer and use it in GitHub Desktop.
Pretty-prints XML file.
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 python3 | |
import argparse | |
from xml.dom import minidom | |
def main(): | |
p = argparse.ArgumentParser(description='Pretty-print an XML file.') | |
p.add_argument('file', type=str, help='File path to print.') | |
args = p.parse_args() | |
data = open(args.file).read() | |
pretty = minidom.parseString(data).toprettyxml(indent=' ') | |
print(pretty) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment