cpython: 17ce3486fd8f (original) (raw)
Mercurial > cpython
changeset 97424:17ce3486fd8f 3.5
Issue #24079: merge from 3.4 [#24079]
Ned Deily nad@acm.org | |
---|---|
date | Mon, 17 Aug 2015 22:11:57 -0400 |
parents | 948d8ea8e7a6(current diff)ad0491f85050(diff) |
children | 3c94ece57c43 637a9d6328f6 |
files | |
diffstat | 1 files changed, 19 insertions(+), 11 deletions(-)[+] [-] Doc/library/xml.etree.elementtree.rst 30 |
line wrap: on
line diff
--- a/Doc/library/xml.etree.elementtree.rst +++ b/Doc/library/xml.etree.elementtree.rst @@ -651,21 +651,29 @@ Element Objects .. attribute:: text
tail[](#l1.7)
The *text* attribute can be used to hold additional data associated with[](#l1.9)
the element. As the name implies this attribute is usually a string but[](#l1.10)
may be any application-specific object. If the element is created from[](#l1.11)
an XML file the attribute will contain any text found between the element[](#l1.12)
tags.[](#l1.13)
These attributes can be used to hold additional data associated with[](#l1.14)
the element. Their values are usually strings but may be any[](#l1.15)
application-specific object. If the element is created from[](#l1.16)
an XML file, the *text* attribute holds either the text between[](#l1.17)
the element's start tag and its first child or end tag, or ``None``, and[](#l1.18)
the *tail* attribute holds either the text between the element's[](#l1.19)
end tag and the next tag, or ``None``. For the XML data[](#l1.20)
.. code-block:: xml[](#l1.22)
<a><b>1<c>2<d/>3</c></b>4</a>[](#l1.25)
The *tail* attribute can be used to hold additional data associated with[](#l1.27)
the element. This attribute is usually a string but may be any[](#l1.28)
application-specific object. If the element is created from an XML file[](#l1.29)
the attribute will contain any text found after the element's end tag and[](#l1.30)
before the next tag.[](#l1.31)
the *a* element has ``None`` for both *text* and *tail* attributes,[](#l1.32)
the *b* element has *text* ``"1"`` and *tail* ``"4"``,[](#l1.33)
the *c* element has *text* ``"2"`` and *tail* ``None``,[](#l1.34)
and the *d* element has *text* ``None`` and *tail* ``"3"``.[](#l1.35)
To collect the inner text of an element, see :meth:`itertext`, for[](#l1.37)
example ``"".join(element.itertext())``.[](#l1.38)
Applications may store arbitrary objects in these attributes.[](#l1.40)