gh-89499: Support the standalone document declaration in ElementTree - #156730
Conversation
…tTree ElementTree.write(), tostring() and tostringlist() get the standalone parameter: True for standalone="yes", False for standalone="no", and None (the default) to omit it. An XML declaration is written if it is not None, and combining it with a false xml_declaration is an error.
Documentation build overview
|
|
|
|
|
|
|
|
|
|
…tTree (pythonGH-156730) ElementTree.write(), tostring() and tostringlist() get the standalone parameter: True for standalone="yes", False for standalone="no", and None (the default) to omit it. An XML declaration is written if it is not None, and combining it with a false xml_declaration is an error.
ElementTree.write(),tostring()andtostringlist()now support the standalone parameter:Trueforstandalone="yes",Falseforstandalone="no", andNone(the default) to omit the standalone document declaration.An XML declaration is written if standalone is not
None, because otherwise it would be omitted for US-ASCII and UTF-8, and the declaration would be lost. Combining it with a false xml_declaration raisesValueError.xml.dom.minidomalready supports this inDocument.writexml(),toxml()andtoprettyxml(), and lxml inwrite()andtostring().standaloneoption #89499