Creating referenceable objects from XML

Fredrik Lundh fredrik at pythonware.com
Mon Dec 12 08:09:14 EST 2005


uche.ogbuji at gmail.com wrote:

> ElementTree ( http://www.xml.com/pub/a/2003/02/12/py-xml.html ) is a
> Python InfoSet rather than a Python data binding.  You access nodes
> using generic names related to the node type rather than the node name.
> Whether data bindings or Infosets are your preference is a matter of
> taste, but it's a useful distinction to make between the approaches.
> It looks as if Gerald Flanagan has constructed a little specialized
> binding tool on top of ElementTree, and that's one possible hybrid
> approach.

in my experience, it's hard to make a python/xml mapping that's well suited for all
possible use cases (many bindings suffer from issues with namespaces, collisions
between tags/attribute names and python names, etc), but it's usually trivial to write
a custom wrapper for a specific case.

for most normal use, manual infoset navigation is often the easiest way to pull out
data from the infoset (find, get, findtext, int, float, etc).

for certain cases, creating wrappers on demand can be quite efficient; e.g.

    http://online.effbot.org/2003_07_01_archive.htm#element-tricks

and for highly regular cases, incremental parsing/conversion up front is often the
fastest and most efficient way to deal with data; e.g.

    http://effbot.org/zone/element-iterparse.htm#plist

</F> 






More information about the Python-list mailing list