Lightning talk for EuroPython 2012 on how to write large XML files with unicode characters and namespaces in Python. The video of the talk is available from http://www.youtube.com/watch?v=f1t2M2wcY2k#t=26m20s. The source code examples can be found at https://gist.github.com/3067859.
11. xml.dom.minidom
Explicit attribute
for name space
Verbose way to
add attributes
Many lines
of code
12. xml.dom.minidom
● “Users [...] who would like to write less code
for processing XML files should consider using
the xml.etree.ElementTree module instead”
(The Python Standard Library, Chapter 19, Structured Markup)
http://www.destructoid.com/blogs/Sevre/femshep-5-a-space-opera-208844.phtml
26. loxun
Supports
with-
statement Streaming interface
for low memory usage
No dependencies
on other modules
Pure Python 2.5+
Optimizes <x></x>
to simply <x/>
27. Raises XmlError if...
● ...you add references to undefined name
spaces
● ...if you forget to close tags (elements)
● ...if you build non-well formed documents
● ...if you add non-ASCII characters in 8-bit
strings
28. Available from:
● http://pypi.python.org/pypi/loxun/
● https://github.com/roskakori/loxun
● Open Source
$ sudo pip install loxun
Downloading/unpacking loxun
Downloading loxun-1.3.zip
Running setup.py egg_info for package loxun
Installing collected packages: loxun
Running setup.py install for loxun
Code examples for this talk: Successfully installed loxun
https://gist.github.com/3067859
29. Try loxun for:
Large output in XML
with Unicode and namespace
Also writes
small ASCII
files!