[Chicago] xml to py object

Kevin Boers KBoers at leapfrogonline.com
Fri May 1 16:24:43 CEST 2009


I like lxml.objectify quite a bit. It does exactly what you're looking for:

http://codespeak.net/lxml/objectify.html

Kevin


On 5/1/09 9:06 AM, "Brennan Todd" <brentodd at gmail.com> wrote:

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 <http://x.ClientApp.Org>
print x.ClientApp.Name <http://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



Kevin P. Boers
QA Manager
847-440-8381

Leapfrog Online
807 Greenwood
Evanston, IL  60201
Main 847-492-1968
Fax  847-492-1990
kboers at leapfrogonline.com
www.leapfrogonline.com

________________________________
CONFIDENTIALITY NOTE
The document(s) accompanying this e-mail transmission, if any, and the e-mail transmittal message containing information from Leapfrog Online Customer Acquisition, LLC is confidential or privileged. The information is intended to be for the use of the individual(s) or entity(ies) named on this e-mail transmission message. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this e-mail is prohibited. If you have received this e-mail in error, please immediately delete this e-mail and notify us by telephone of the error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090501/452156d2/attachment-0001.htm>


More information about the Chicago mailing list