serialize a class to XML and back

Chris Rebert clp2 at rebertia.com
Sun May 26 16:36:53 EDT 2013


On May 23, 2013 3:42 AM, "Schneider" <js at globe.de> wrote:
>
> Hi list,
>
> how can I serialize a python class to XML? Plus a way to get the class
back from the XML?

There's pyxser: http://pythonhosted.org/pyxser/

> My aim is to store instances of this class in a database.

Honestly, I would avoid XML if you can. Consider using JSON (Python
includes the `json` module in the std lib) or pickle instead. Compared to
XML: The former is more standardized (in the context of serializing
objects) and less verbose; the latter is more efficient (if you don't care
about cross-language accessibility); both have more convenient APIs.

Cheers,
Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130526/91efa92b/attachment.html>


More information about the Python-list mailing list