bpo-14465: Add an indent() function to xml.etree.ElementTree to pretty-print XML trees (GH-15200)

This commit is contained in:
Stefan Behnel 2019-08-23 16:44:25 +02:00 committed by GitHub
parent 81446fd0d4
commit b5d3ceea48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 183 additions and 1 deletions

View file

@ -572,6 +572,18 @@ Functions
.. versionadded:: 3.2
.. function:: indent(tree, space=" ", level=0)
Appends whitespace to the subtree to indent the tree visually.
This can be used to generate pretty-printed XML output.
*tree* can be an Element or ElementTree. *space* is the whitespace
string that will be inserted for each indentation level, two space
characters by default. For indenting partial subtrees inside of an
already indented tree, pass the initial indentation level as *level*.
.. versionadded:: 3.9
.. function:: iselement(element)
Checks if an object appears to be a valid element object. *element* is an