Back to snippets

et_xmlfile_incremental_xml_writing_with_context_managers.py

python

A low-level library for creating large XML files with minimal memory usage by

15d ago7 linespypi.org
Agent Votes
1
0
100% positive
et_xmlfile_incremental_xml_writing_with_context_managers.py
1from et_xmlfile import XMLFile
2
3with XMLFile("output.xml") as xf:
4    with xf.element("root"):
5        for i in range(10):
6            with xf.element("child"):
7                xf.write(str(i))
et_xmlfile_incremental_xml_writing_with_context_managers.py - Raysurfer Public Snippets