summaryrefslogtreecommitdiffstats
path: root/Doc/library/xml.etree.elementtree.rst
diff options
context:
space:
mode:
authorBernt Røskar Brenna <bernt.brenna@gmail.com>2019-04-14 08:07:02 (GMT)
committerStefan Behnel <stefan_ml@behnel.de>2019-04-14 08:07:02 (GMT)
commitffca16e25a70fd44a87b13b379b5ec0c7a11e926 (patch)
tree6855e55ff815720daf989ebc6e8eab778b197f73 /Doc/library/xml.etree.elementtree.rst
parent830b43d03cc47a27a22a50d777f23c8e60820867 (diff)
downloadcpython-ffca16e25a70fd44a87b13b379b5ec0c7a11e926.zip
cpython-ffca16e25a70fd44a87b13b379b5ec0c7a11e926.tar.gz
cpython-ffca16e25a70fd44a87b13b379b5ec0c7a11e926.tar.bz2
bpo-36227: ElementTree.tostring() default_namespace and xml_declaration arguments (GH-12225)
Add new keyword arguments "default_namespace" and "xml_declaration" to functions ET.tostring() and ET.tostringlist(), as known from ElementTree.write().
Diffstat (limited to 'Doc/library/xml.etree.elementtree.rst')
-rw-r--r--Doc/library/xml.etree.elementtree.rst21
1 files changed, 15 insertions, 6 deletions
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index 4a7cf6f..9bee0ea 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -594,6 +594,7 @@ Functions
.. function:: tostring(element, encoding="us-ascii", method="xml", *, \
+ xml_declaration=None, default_namespace=None,
short_empty_elements=True)
Generates a string representation of an XML element, including all
@@ -601,14 +602,19 @@ Functions
the output encoding (default is US-ASCII). Use ``encoding="unicode"`` to
generate a Unicode string (otherwise, a bytestring is generated). *method*
is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``).
- *short_empty_elements* has the same meaning as in :meth:`ElementTree.write`.
- Returns an (optionally) encoded string containing the XML data.
+ *xml_declaration*, *default_namespace* and *short_empty_elements* has the same
+ meaning as in :meth:`ElementTree.write`. Returns an (optionally) encoded string
+ containing the XML data.
.. versionadded:: 3.4
The *short_empty_elements* parameter.
+ .. versionadded:: 3.8
+ The *xml_declaration* and *default_namespace* parameters.
+
.. function:: tostringlist(element, encoding="us-ascii", method="xml", *, \
+ xml_declaration=None, default_namespace=None,
short_empty_elements=True)
Generates a string representation of an XML element, including all
@@ -616,16 +622,19 @@ Functions
the output encoding (default is US-ASCII). Use ``encoding="unicode"`` to
generate a Unicode string (otherwise, a bytestring is generated). *method*
is either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``).
- *short_empty_elements* has the same meaning as in :meth:`ElementTree.write`.
- Returns a list of (optionally) encoded strings containing the XML data.
- It does not guarantee any specific sequence, except that
- ``b"".join(tostringlist(element)) == tostring(element)``.
+ *xml_declaration*, *default_namespace* and *short_empty_elements* has the same
+ meaning as in :meth:`ElementTree.write`. Returns a list of (optionally) encoded
+ strings containing the XML data. It does not guarantee any specific sequence,
+ except that ``b"".join(tostringlist(element)) == tostring(element)``.
.. versionadded:: 3.2
.. versionadded:: 3.4
The *short_empty_elements* parameter.
+ .. versionadded:: 3.8
+ The *xml_declaration* and *default_namespace* parameters.
+
.. function:: XML(text, parser=None)