[Chicago] xml to py object

Brennan Todd brentodd at gmail.com
Fri May 1 16:06:10 CEST 2009


Chapter 12 of the Python Cookbook has something that might work for you.
It's available through google book search:

http://www.google.com/url?sa=t&source=web&ct=res&cd=5&url=http%3A%2F%2Fbooks.google.com%2Fbooks%3Fid%3DQ0s6Vgb98CQC%26pg%3DPA463%26lpg%3DPA463%26dq%3Dpython%2Bcookbook%2Bxml%26source%3Dbl%26ots%3Dhc1X49Thxy%26sig%3DZWPKo9xnYLwcEiYkX6H1J2QD9nM%26hl%3Den%26ei%3DVgD7SeP4EJbCMsilzbUE%26sa%3DX%26oi%3Dbook_result%26ct%3Dresult%26resnum%3D5&ei=VgD7SeP4EJbCMsilzbUE&usg=AFQjCNGG0TwqVNpAXUN9UMEerFjFS0ZGBQ&sig2=o24zRdkRigZeEeOjKzdkpw

I've used the recipe once or twice, and it's easy enough to modify for your
specific needs.

On Fri, May 1, 2009 at 8:34 AM, Lukasz Szybalski <szybalski at gmail.com>wrote:

> Hello,
> I'm trying to convert an xml to python like object where:
>
>      <ClientApp>
>            <Org>my company</Org>
>             <Name>Full name of the comapny</Name>
>            <Version>1.02 (4.02)</Version>
>        </ClientApp>
>
> would correspond to
>
> class someobject(object):........
>
> and would be accessible via something like:
>
> print x.ClientApp.Org
> print x.ClientApp.Name
> print x.ClientApp.Version
>
> Not sure how things like this would be implemented:
>
>  <Vehicle id="Veh_1" LocationRef="Location_1" DriverRef="Driver_1"/>
>
> Is there a module/library that is able convert the xml into something like
> this?
>
> Thanks,
> Lucas
>
>
> --
> How to create python package?
> http://lucasmanual.com/mywiki/PythonPaste
> DataHub - create a package that gets, parses, loads, visualizes data
> http://lucasmanual.com/mywiki/DataHub
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090501/774872d2/attachment.htm>


More information about the Chicago mailing list