Skip to content

Instantly share code, notes, and snippets.

Last active Apr 25, 2019
What would you like to do?
remove carriage returns in an XML file
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