Staging: this is not the live site, pydocs.org.
Structured Markup Processing Tools
Element class. This class defines the Element interface, and provides a reference implementation of this interface.
Changed in 3.12, 3.15
- 3.12: Testing the truth value of an Element emits DeprecationWarning.
- 3.15: attrib can now be a frozendict.
- 3.15: tag is now a positional-only parameter.
Members of Element
a
- append
- Adds the element subelement to the end of this element’s internal list of subelements.
- attrib
- A dictionary containing the element's attributes
e
- extend
- Appends subelements from an iterable of elements.
f
- find
- Finds the first subelement matching match.
- findall
- Finds all matching subelements, by tag name or path.
- findtext
- Finds text for the first subelement matching match.
g
- get
- Gets the element attribute named key.
i
- insert
- Inserts subelement at the given position in this element.
- items
- Returns the element attributes as (name, value) pairs.
- iter
- Creates a tree iterator with the current element as the root.
- iterfind
- Finds all matching subelements, by tag name or path.
k
- keys
- Returns the element attribute names.
m
- makeelement
- Creates a new element object of the same type as this element.
r
- remove
- Removes subelement from the element.
s
- set
- Set the attribute key on the element to value.
t
- tag
- A string identifying what kind of data this element represents
- tail
- A string of text directly after the end tag, or None
- text
- A string of text directly after the start tag, or None