PyDocs

Nav

Structured Markup Processing Tools

Element

  • Element(tag, /, attrib={}, **extra)
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

c

clear
Resets an element.

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.
itertext
Creates a text iterator.

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
0 Examples
No examples for xml.etree.ElementTree/Element.
See Also
No see-alsos for xml.etree.ElementTree/Element
0 Notes
No notes for Element