mirror of https://github.com/python/cpython.git
Issue #24079: merge from 3.4
This commit is contained in:
commit
d61714d236
|
@ -651,21 +651,29 @@ Element Objects
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: text
|
.. attribute:: text
|
||||||
|
tail
|
||||||
|
|
||||||
The *text* attribute can be used to hold additional data associated with
|
These attributes can be used to hold additional data associated with
|
||||||
the element. As the name implies this attribute is usually a string but
|
the element. Their values are usually strings but may be any
|
||||||
may be any application-specific object. If the element is created from
|
application-specific object. If the element is created from
|
||||||
an XML file the attribute will contain any text found between the element
|
an XML file, the *text* attribute holds either the text between
|
||||||
tags.
|
the element's start tag and its first child or end tag, or ``None``, and
|
||||||
|
the *tail* attribute holds either the text between the element's
|
||||||
|
end tag and the next tag, or ``None``. For the XML data
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
.. attribute:: tail
|
<a><b>1<c>2<d/>3</c></b>4</a>
|
||||||
|
|
||||||
The *tail* attribute can be used to hold additional data associated with
|
the *a* element has ``None`` for both *text* and *tail* attributes,
|
||||||
the element. This attribute is usually a string but may be any
|
the *b* element has *text* ``"1"`` and *tail* ``"4"``,
|
||||||
application-specific object. If the element is created from an XML file
|
the *c* element has *text* ``"2"`` and *tail* ``None``,
|
||||||
the attribute will contain any text found after the element's end tag and
|
and the *d* element has *text* ``None`` and *tail* ``"3"``.
|
||||||
before the next tag.
|
|
||||||
|
To collect the inner text of an element, see :meth:`itertext`, for
|
||||||
|
example ``"".join(element.itertext())``.
|
||||||
|
|
||||||
|
Applications may store arbitrary objects in these attributes.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: attrib
|
.. attribute:: attrib
|
||||||
|
|
Loading…
Reference in New Issue