Skip to content

Instantly share code, notes, and snippets.

@hugoledoux
Last active Apr 25, 2019
Embed
What would you like to do?
remove carriage returns in an XML file
#!/usr/local/bin/python
from lxml import etree
import sys
fin = sys.argv[1]
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(fin, parser)
root = tree.getroot()
sys.stdout.write(etree.tostring(root, pretty_print=False, xml_declaration=True, encoding="UTF-8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment