[Python-Dev] c/ElementTree XML serialisation

Alex Leach albl500 at york.ac.uk
Tue May 8 19:46:47 CEST 2012


Furthermore, if I use the "html" method (an option given to 
ElementTree.write), closing tags are converted to lower case, which leads to 
an XML parsing error with camel-cased tag names.
Using the "text" method instead removes all tags, and I get a ValueError if I 
try to use the "c14n" method.

This seems like a limitation in ElementTree.py only, as _elementtree.c doesn't 
appear to contain any of these serialization or writing methods.

What I think I'll do is write a _serialise_svg function and add it to the 
_serialize dictionary of function lookups, from the module I'm working on. 
That way I hope I can pass method="svg" to ElementTree's write() method; it 
should work, and it should also be backwards-compatible.

That should be quite a quick and easy fix actually. Would this be something 
worth incorporating into ElementTree downstream?

Kind regards,
Alex




More information about the Python-Dev mailing list