mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-37534: Allow adding Standalone Document Declaration when generating XML documents (GH-14912)
This commit is contained in:
parent
02673352b5
commit
dc04a0571e
5 changed files with 51 additions and 13 deletions
|
@ -132,7 +132,8 @@ module documentation. This section lists the differences between the API and
|
|||
... # Work with dom.
|
||||
|
||||
|
||||
.. method:: Node.writexml(writer, indent="", addindent="", newl="")
|
||||
.. method:: Node.writexml(writer, indent="", addindent="", newl="",
|
||||
encoding=None, standalone=None)
|
||||
|
||||
Write XML to the writer object. The writer receives texts but not bytes as input,
|
||||
it should have a :meth:`write` method which matches that of the file object
|
||||
|
@ -144,11 +145,18 @@ module documentation. This section lists the differences between the API and
|
|||
For the :class:`Document` node, an additional keyword argument *encoding* can
|
||||
be used to specify the encoding field of the XML header.
|
||||
|
||||
Silimarly, explicitly stating the *standalone* argument causes the
|
||||
standalone document declarations to be added to the prologue of the XML
|
||||
document.
|
||||
If the value is set to `True`, `standalone="yes"` is added,
|
||||
otherwise it is set to `"no"`.
|
||||
Not stating the argument will omit the declaration from the document.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
The :meth:`writexml` method now preserves the attribute order specified
|
||||
by the user.
|
||||
|
||||
.. method:: Node.toxml(encoding=None)
|
||||
.. method:: Node.toxml(encoding=None, standalone=None)
|
||||
|
||||
Return a string or byte string containing the XML represented by
|
||||
the DOM node.
|
||||
|
@ -160,11 +168,14 @@ module documentation. This section lists the differences between the API and
|
|||
encoding. Encoding this string in an encoding other than UTF-8 is
|
||||
likely incorrect, since UTF-8 is the default encoding of XML.
|
||||
|
||||
The *standalone* argument behaves exactly as in :meth:`writexml`.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
The :meth:`toxml` method now preserves the attribute order specified
|
||||
by the user.
|
||||
|
||||
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None)
|
||||
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None,
|
||||
standalone=None)
|
||||
|
||||
Return a pretty-printed version of the document. *indent* specifies the
|
||||
indentation string and defaults to a tabulator; *newl* specifies the string
|
||||
|
@ -173,6 +184,8 @@ module documentation. This section lists the differences between the API and
|
|||
The *encoding* argument behaves like the corresponding argument of
|
||||
:meth:`toxml`.
|
||||
|
||||
The *standalone* argument behaves exactly as in :meth:`writexml`.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
The :meth:`toprettyxml` method now preserves the attribute order specified
|
||||
by the user.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue