Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '(python': 0.07; 'context': 0.07; 'json': 0.07; 'latter': 0.09; 'objects)': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; '23,': 0.16; 'apis.': 0.16; 'subject:XML': 0.16; 'subject:class': 0.16; 'wrote:': 0.18; 'module': 0.19; '(in': 0.22; 'cc:addr:python.org': 0.22; 'convenient': 0.24; 'instead.': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'xml': 0.29; 'compared': 0.30; 'message- id:@mail.gmail.com': 0.30; 'pickle': 0.31; 'class': 0.32; 'received:google.com': 0.35; 'instances': 0.36; 'url:org': 0.36; 'list,': 0.38; 'skip:& 20': 0.39; 'how': 0.40; 'subject:back': 0.60; 'back': 0.62; 'more': 0.64; 'sender:addr:chris': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=2ePs/+XJkeRGU4p6zJeZX8mmCfTyPCLHveGqf66jeaI=; b=DArrGMU5KacdwZMZuovL+IQCA8kzQIfAfPVLAMJxs5P0uZhZzIIwg4c1FUobKWcsWh Kw4ikG2L4CX0tXNxFDNP36fyj3l85XFdNFyUBHMI+FTzgxt/+yp41BCWiVWhBTHuLjLf rMDBrFXputuab8kKBX1VZUqlrx3u/jdE7DHns= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=2ePs/+XJkeRGU4p6zJeZX8mmCfTyPCLHveGqf66jeaI=; b=o6fXhVEixH+7huYUs5B0jriDompvV+vmEYXTaBTjtKlzM3NmroL+guUs+02KxdhWzL qRecGn3T83JzlS3V51zx57VrsO2R5GTq//UB1qR47AgD0JGRYvr8XVzdIwmGFOSu6FPD 9uGvwfUFF3A/UrkNqPNilWTtr3C8aJxmb7Bs1C7tymePopPN7ekaLUU6AITeHFuKWVv0 eXMsHBDX8cAobPLJ6YDtzv5tvyFqoa+SG5PcGTShS/OlWMduc74HWuULLEX141Nm0qGv mil6lU+kRbJgXzX2HAtKRtzFMmpgP0V3MavKrg2K6ahDWtfNEqkSITnqdbarixb2c1ul 0r8g== MIME-Version: 1.0 X-Received: by 10.50.22.98 with SMTP id c2mr2908948igf.52.1369600613944; Sun, 26 May 2013 13:36:53 -0700 (PDT) Sender: chris@rebertia.com In-Reply-To: <519DF151.1080405@globe.de> References: <519DF151.1080405@globe.de> Date: Sun, 26 May 2013 13:36:53 -0700 X-Google-Sender-Auth: V6YYnA7apip0ajcX8nXwSpwKZeY Subject: Re: serialize a class to XML and back From: Chris Rebert To: Schneider Content-Type: multipart/alternative; boundary=089e0158bb1a14251104dda4fecc X-Gm-Message-State: ALoCoQnugS4PLv8OjDZeWaDnLO0bkEDgC/2woelZcCWq8rsGhl65t8CzF7KJic4QuSHFMUSRYgQ4 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369600623 news.xs4all.nl 15974 [2001:888:2000:d::a6]:58032 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46114 --089e0158bb1a14251104dda4fecc Content-Type: text/plain; charset=UTF-8 On May 23, 2013 3:42 AM, "Schneider" 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 --089e0158bb1a14251104dda4fecc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

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 databas= e.

Honestly, I would avoid XML if you can. Consider using JSON = (Python includes the `json` module in the std lib) or pickle instead. Compa= red 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 c= are about cross-language accessibility); both have more convenient APIs.

Cheers,
Chris

--089e0158bb1a14251104dda4fecc--