How do I parse and write XML using Python’s ElementTree without moving namespaces around?
As far as I know the solution that better suits your needs is to write a pure Python custom rendering using the features exposed by xml.etree.ElementTree. Here is one possible solution: from xml.etree import ElementTree as ET from re import findall, sub def render(root, buffer=””, namespaces=None, level=0, indent_size=2, encoding=’utf-8′): buffer += f'<?xml version=”1.0″ encoding=”{encoding}” ?>\n’ … Read more