et-xmlfile
A low-memory library for creating large XML files, implementing lxml's xmlfile module for the standard library. Current version: 2.0.0, released on October 25, 2024. Maintained by CharlieX. Requires Python 3.8 or higher. Release cadence: approximately every 3 years.
Warnings
- gotcha Using the .element() method on the xmlfile context manager may negatively affect performance. It's recommended to create Elements and write them directly.
Install
-
pip install et-xmlfile
Imports
- xmlfile
from et_xmlfile import xmlfile
Quickstart
from io import BytesIO
from xml.etree.ElementTree import Element
from et_xmlfile import xmlfile
out = BytesIO()
with xmlfile(out) as xf:
el = Element('root')
xf.write(el)
assert out.getvalue() == b'<root />'