Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46114

Re: serialize a class to XML and back

References <519DF151.1080405@globe.de>
Date 2013-05-26 13:36 -0700
Subject Re: serialize a class to XML and back
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.2197.1369600623.3114.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On May 23, 2013 3:42 AM, "Schneider" <js@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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: serialize a class to XML and back Chris Rebert <clp2@rebertia.com> - 2013-05-26 13:36 -0700
  Re: serialize a class to XML and back Roy Smith <roy@panix.com> - 2013-05-26 16:48 -0400
    Re: serialize a class to XML and back Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-05-27 00:40 +0200
      Re: serialize a class to XML and back Roy Smith <roy@panix.com> - 2013-05-26 20:39 -0400
        Re: serialize a class to XML and back Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-05-27 20:45 +0200
    Re: serialize a class to XML and back Schneider <js@globe.de> - 2013-05-31 13:21 +0200

csiph-web