Skip to content

Instantly share code, notes, and snippets.

@dhumanity
Created December 12, 2022 15:41
Show Gist options
  • Save dhumanity/1625a4815248e1e079b146cf3d97600a to your computer and use it in GitHub Desktop.
Save dhumanity/1625a4815248e1e079b146cf3d97600a to your computer and use it in GitHub Desktop.
pretty print XML on python3, originally to python2 from https://gist.github.com/rspivak/74a08170a2a04a344161
alias ppxml='python3 -c "import sys, io;from lxml import etree;print(etree.tostring(etree.parse(io.StringIO(sys.stdin.read()),etree.XMLParser(remove_blank_text = True)), pretty_print = True).decode(\"utf-8\"))"'
@dhumanity
Copy link
Author

After adding this alias into .bash_profile and re-sourcing it.
Usage is as simple as feeding the alias the stdin

cat notpretty.xml | ppxml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment