PyDocs

Nav

Structured Markup Processing Tools

tostringlist

xml.etree.ElementTree

function · Added in 3.2 (source)
  • 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 subelements. element is an Element instance. encoding [1] is 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"). xml_declaration, default_namespace and short_empty_elements has the same meaning as in 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).
Changed in 3.4, 3.8
  • 3.4: Added the short_empty_elements parameter.
  • 3.8: Added the xml_declaration and default_namespace parameters.
  • 3.8: The tostringlist() function now preserves the attribute order specified by the user.
0 Examples
No examples for xml.etree.ElementTree/tostringlist.
See Also
No see-alsos for xml.etree.ElementTree/tostringlist
0 Notes
No notes for tostringlist