Creating referenceable objects from XML

rurpy at yahoo.com rurpy at yahoo.com
Mon Dec 5 00:41:47 EST 2005


Michael Williams wrote:
> Hi All,
>
> I'm looking for a quality Python XML implementation.  All of the DOM
> and SAX implementations I've come across so far are rather
> convoluted.  Are there any quality implementations that will (after
> parsing the XML) return an object that is accessible by name? Such as
> the following:
>
>
> xml = """
> <book>
> 	<title>MyBook</title>
> 	<author>the author</author>
> </book>
> """
>
> And after parsing the XML allow me to access it as so:
>
> book.title
>
> I need it to somehow convert my XML to intuitively referenceable
> object.  Any ideas?  I could even do it myself if I knew the
> mechanism by which python classes do this (create variables on the fly).
>
> Thanks in advance!

You might want to take a look at Fredrik Lundh's ElementTree
(and cElementTree) modules:
http://effbot.org/zone/element-index.htm




More information about the Python-list mailing list