find() method in ElementTree

Fredrik Lundh fredrik at pythonware.com
Sat Oct 22 14:08:38 EDT 2005


mirandacascade at yahoo.com wrote:

> My questions:
> 1) in the example above is there a subelement of doc with a tag
> 'SampleDetails'?

find only searches for direct subelements; SampleDetail is not a direct
subelement to SampleRoot, since there's a SpecificInformation element
in between.

> 2) if so, what is the proper way of writing the call to the find()
> method to locate that subelement?

    elem = doc.find(".//SampleDetail")

should work.

</F>






More information about the Python-list mailing list