xml.etree.ElementTree.TreeBuilder.data()

data(data) Adds text to the current element. data is a string. This should be either a bytestring, or a Unicode string.

xml.etree.ElementTree.TreeBuilder.close()

close() Flushes the builder buffers, and returns the toplevel document element. Returns an Element instance.

xml.etree.ElementTree.TreeBuilder

class xml.etree.ElementTree.TreeBuilder(element_factory=None) Generic element structure builder. This builder converts a sequence of start, data, and end method calls to a well-formed element structure. You can use this class to build an element structure using a custom XML parser, or a parser for some other XML-like format. element_factory, when given, must be a callable accepting two positional arguments: a tag and a dict of attributes. It is expected to return a new element instance. clo

xml.etree.ElementTree.tostringlist()

xml.etree.ElementTree.tostringlist(element, encoding="us-ascii", method="xml", *, 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"). short_empty_elements has the same meaning as in ElementTree.wri

xml.etree.ElementTree.tostring()

xml.etree.ElementTree.tostring(element, encoding="us-ascii", method="xml", *, 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"). short_empty_elements has the same meaning as in ElementTree.write()

xml.etree.ElementTree.SubElement()

xml.etree.ElementTree.SubElement(parent, tag, attrib={}, **extra) Subelement factory. This function creates an element instance, and appends it to an existing element. The element name, attribute names, and attribute values can be either bytestrings or Unicode strings. parent is the parent element. tag is the subelement name. attrib is an optional dictionary, containing element attributes. extra contains additional attributes, given as keyword arguments. Returns an element instance.

xml.etree.ElementTree.register_namespace()

xml.etree.ElementTree.register_namespace(prefix, uri) Registers a namespace prefix. The registry is global, and any existing mapping for either the given prefix or the namespace URI will be removed. prefix is a namespace prefix. uri is a namespace uri. Tags and attributes in this namespace will be serialized with the given prefix, if at all possible. New in version 3.2.

xml.etree.ElementTree.QName

class xml.etree.ElementTree.QName(text_or_uri, tag=None) QName wrapper. This can be used to wrap a QName attribute value, in order to get proper namespace handling on output. text_or_uri is a string containing the QName value, in the form {uri}local, or, if the tag argument is given, the URI part of a QName. If tag is given, the first argument is interpreted as a URI, and this argument is interpreted as a local name. QName instances are opaque.

xml.etree.ElementTree.ProcessingInstruction()

xml.etree.ElementTree.ProcessingInstruction(target, text=None) PI element factory. This factory function creates a special element that will be serialized as an XML processing instruction. target is a string containing the PI target. text is a string containing the PI contents, if given. Returns an element instance, representing a processing instruction. Note that XMLParser skips over processing instructions in the input instead of creating comment objects for them. An ElementTree will only

xml.etree.ElementTree.ParseError.position

position A tuple of line, column numbers, specifying where the error occurred.