Next / Previous / Contents / TCC Help System / NM Tech homepage

7.3. ElementTree.findtext(): Retrieve the text content from an element

To retrieve the text inside some element, use this method on some ElementTree instance ET:

ET.findtext ( path, default=None ):
path

The syntax for describing the location of the desired element is the same as in Section 7.1, “ElementTree.find().

default

The value to be returned if there is no element at that path.

If there is a child at the indicated path, the method returns its text content as a string. If there is a matching child, but it has no content, the return value is "" (the empty string). If there is no such child, the method returns None.