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

9. class Element: One element in the tree

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

9.1. Attributes of an Element instance

Each instance of the Element class has these attributes.

.attrib

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

.base

The base URI from an xml:base attribute that this element contains or inherits, if any; None otherwise.

.prefix

The namespace prefix of this element, if any, otherwise None.

.sourceline

The line number of this element when parsed, if known, otherwise None.

.tag

The element's name.

.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.