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

8. class Element: One element in the tree

Each XML element is represented by an instance of the Element class.

8.1. Attributes of an Element instance

Each instance of the Element class has these attributes.

.tag

The element's name.

.attrib

A dictionary containing the element's attributes. The keys are the attribute names, and each corresponding value is the attribute's value.

.tail

The text following this element's closing tag, up to the start tag of the next sibling element. If there was no text there, this attribute will have the value None.

This way of associating text with elements is not really typical of the way most XML processing models work; see Section 2, “How ElementTree represents XML”.

.text

The text inside the element, up to the start tag of the first child element. If there was no text there, this attribute will have the value None.