Skip to content

Commit 26cadbb

Browse files
Document what can be the element name, the attributes and the text
They are strings or QName instances, and the text and the tail can also be None. The element name can also be Comment, ProcessingInstruction or None, and the attribute value can be None for the HTML method.
1 parent d502d73 commit 26cadbb

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Doc/library/xml.etree.elementtree.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,18 @@ Element Objects
891891
an optional dictionary, containing element attributes. *extra* contains
892892
additional attributes, given as keyword arguments.
893893

894+
The element name and the attribute names and values are strings or
895+
:class:`QName` instances, and the text and the tail are strings or
896+
``None``.
897+
The element name can also be :func:`Comment` or
898+
:func:`ProcessingInstruction`, which are used for special elements.
899+
If it is ``None``, the element itself is not serialized: only its text
900+
and its children are written, and its attributes are ignored.
901+
This can be used for a fragment which contains several elements.
902+
With ``method="html"`` the attribute value can also be ``None``,
903+
which produces an empty attribute (such as ``checked``).
904+
Other objects can be stored in the tree, but they cannot be serialized.
905+
894906
.. versionchanged:: 3.15
895907
*attrib* can now be a :class:`frozendict`.
896908

0 commit comments

Comments
 (0)