[FRPythoneers] looking for help with elementtree

Uche Ogbuji uche.ogbuji at fourthought.com
Sat Jun 28 08:12:33 MDT 2003

> After reading in an element tree from XML, I get
> an element from the tree like this:
>     properties = tree.find('PROPERTIES')
> If I wrap properties in an ElementTree and write, the XML
> output is:
> <PROPERTIES><ENVELOPE minx="-106" maxx="-105" miny="40" maxy="41"/>


> however, I am not able to find the ENVELOPE element under
>      properties.find('ENVELOPE')
> returns None.
> How can find() return None when I am finding an element tagged 
> when iterating over properties?

find() acts differently depending on the instance on which you invoke it.  See 
if properties.getroot().find(path) does what you want.

Frankly, find() has always bewildered me.  And I think it's in a bit of flux 
as /F works in his experimental XPath implementation.

Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
XML Data Bindings in Python - http://www.xml.com/pub/a/2003/06/11/py-xml.html
Introducing Examplotron - http://www-106.ibm.com/developerworks/xml/library/x-x
Charming Jython - http://www-106.ibm.com/developerworks/java/library/j-jython.h
The commons of creativity - http://www-106.ibm.com/developerworks/xml/library/x
A custom-fit career in app development - http://www.adtmag.com/article.asp?id=7

More information about the FRPythoneers mailing list