MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / tostring

Function tostring

tools/python-3.11.9-amd64/Lib/xml/etree/ElementTree.py:1082–1104  ·  view source on GitHub ↗

Generate string representation of XML element. All subelements are included. If encoding is "unicode", a string is returned. Otherwise a bytestring is returned. *element* is an Element instance, *encoding* is an optional output encoding defaulting to US-ASCII, *method* is an

(element, encoding=None, method=None, *,
             xml_declaration=None, default_namespace=None,
             short_empty_elements=True)

Source from the content-addressed store, hash-verified

1080# --------------------------------------------------------------------
1081
1082def tostring(element, encoding=None, method=None, *,
1083 xml_declaration=None, default_namespace=None,
1084 short_empty_elements=True):
1085 """Generate string representation of XML element.
1086
1087 All subelements are included. If encoding is "unicode", a string
1088 is returned. Otherwise a bytestring is returned.
1089
1090 *element* is an Element instance, *encoding* is an optional output
1091 encoding defaulting to US-ASCII, *method* is an optional output which can
1092 be one of "xml" (default), "html", "text" or "c14n", *default_namespace*
1093 sets the default XML namespace (for "xmlns").
1094
1095 Returns an (optionally) encoded string containing the XML data.
1096
1097 """
1098 stream = io.StringIO() if encoding == 'unicode' else io.BytesIO()
1099 ElementTree(element).write(stream, encoding,
1100 xml_declaration=xml_declaration,
1101 default_namespace=default_namespace,
1102 method=method,
1103 short_empty_elements=short_empty_elements)
1104 return stream.getvalue()
1105
1106class _ListDataStream(io.BufferedIOBase):
1107 """An auxiliary stream accumulating into a list reference."""

Callers

nothing calls this directly

Calls 3

ElementTreeClass · 0.85
writeMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected