Module for converting XML to Python object(s)?

Uche Ogbuji uche at ogbuji.net
Mon Aug 9 10:35:12 EDT 2004


François Pinard <pinard at iro.umontreal.ca> wrote in message news:<mailman.1033.1091401922.5135.python-list at python.org>...
> [Robert Oschler]
> > Has anybody seen a Python module that will take an XML document (not a
> > colossal one), and convert it to a Python nested class object?
> 
> You might want to check this announcement:
> 
>         From: "Fredrik Lundh" <fredrik at pythonware.com>
>         Date: Fri, 18 Jun 2004 17:07:43 +0200
>         Subject: ANN: ElementTree 1.2 final (june 18, 2004)
>         To: python-announce-list at python.org
>         Newsgroups: comp.lang.python.announce
> 
>         The Element type is a simple but flexible container object,
>         designed to store hierarchical data structures, such as
>         simplified XML infosets, in memory.  The ElementTree package
>         provides a Python implementation of this type, plus code to
>         serialize element trees to and from XML files.

ElementTree rocks, but is not really what I understood the OP's
request to be.  It seems he wants specialized classes matching the XML
vocabulary, e.g.

print html.head.title

You can't really do this with ElementTree.  This is the preserve of a
different class of XML libraries, called data bindings.  I discussed
data bindings I know of in my previous response to the OP.  Oluyede
reminded me of XMLObject.  Also, both Eric van der Vlist and Guido van
Rossum himself have done recent work in data bindings for XML/Python. 
Neither's work is packaged for public release yet, though.


-- 
Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Perspective on XML: Steady steps spell success with Google -
http://www.adtmag.com/article.asp?id=9663
Use XML namespaces with care -
http://www-106.ibm.com/developerworks/xml/library/x-namcar.html
Managing XML libraries - http://www.adtmag.com/article.asp?id=9160
Commentary on "Objects. Encapsulation. XML?" -
http://www.adtmag.com/article.asp?id=9090
Harold's Effective XML -
http://www.ibm.com/developerworks/xml/library/x-think25.html
A survey of XML standards -
http://www-106.ibm.com/developerworks/xml/library/x-stand4/



More information about the Python-list mailing list