neulab/docprompting-conala huggingface dataset:
Node.toxml(encoding=None, standalone=None)  
Return a string or byte string containing the XML represented by the DOM node. With an explicit encoding 1 argument, the result is a byte string in the specified encoding. With no encoding argument, the result is a Unicode string, and the XML declaration in the resulting string does not specify an encoding. Encoding this string in an encoding other than UTF-8 is likely incorrect, since UTF-8 is the default encoding of XML. The standalone argument behaves exactly as in writexml().  Changed in version 3.8: The toxml() method now preserves the attribute order specified by the user.
Node.unlink()  
Break internal references within the DOM so that it will be garbage collected on versions of Python without cyclic GC. Even when cyclic GC is available, using this can make large amounts of memory available sooner, so calling this on DOM objects as soon as they are no longer needed is good practice. This only needs to be called on the Document object, but may be called on child nodes to discard children of that node. You can avoid calling this method explicitly by using the with statement. The following code will automatically unlink dom when the with block is exited: with xml.dom.minidom.parse(datasource) as dom:
    ... # Work with dom.
Node.writexml(writer, indent="", addindent="", newl="", encoding=None, standalone=None)  
Write XML to the writer object. The writer receives texts but not bytes as input, it should have a write() method which matches that of the file object interface. The indent parameter is the indentation of the current node. The addindent parameter is the incremental indentation to use for subnodes of the current one. The newl parameter specifies the string to use to terminate newlines. For the Document node, an additional keyword argument encoding can be used to specify the encoding field of the XML header. Silimarly, explicitly stating the standalone argument causes the standalone document declarations to be added to the prologue of the XML document. If the value is set to True, standalone=”yes” is added, otherwise it is set to “no”. Not stating the argument will omit the declaration from the document.  Changed in version 3.8: The writexml() method now preserves the attribute order specified by the user.
xml.dom.minidom.parse(filename_or_file, parser=None, bufsize=None)  
Return a Document from the given input. filename_or_file may be either a file name, or a file-like object. parser, if given, must be a SAX2 parser object. This function will change the document handler of the parser and activate namespace support; other parser configuration (like setting an entity resolver) must have been done in advance.
xml.dom.minidom.parseString(string, parser=None)  
Return a Document that represents the string. This method creates an io.StringIO object for the string and passes that on to parse().
NamedNodeMap.item(index)  
Return an attribute with a particular index. The order you get the attributes in is arbitrary but will be consistent for the life of a DOM. Each item is an attribute node. Get its value with the value attribute.
exception xml.dom.NamespaceErr  
If an attempt is made to change any object in a way that is not permitted with regard to the Namespaces in XML recommendation, this exception is raised.
exception xml.dom.NoDataAllowedErr  
This is raised if data is specified for a node which does not support data.
Node.appendChild(newChild)  
Add a new child node to this node at the end of the list of children, returning newChild. If the node was already in the tree, it is removed first.
Node.attributes  
A NamedNodeMap of attribute objects. Only elements have actual values for this; others provide None for this attribute. This is a read-only attribute.
Node.childNodes  
A list of nodes contained within this node. This is a read-only attribute.
Node.cloneNode(deep)  
Clone this node. Setting deep means to clone all child nodes as well. This returns the clone.
Node.firstChild  
The first child of the node, if there are any, or None. This is a read-only attribute.
Node.insertBefore(newChild, refChild)  
Insert a new child node before an existing child. It must be the case that refChild is a child of this node; if not, ValueError is raised. newChild is returned. If refChild is None, it inserts newChild at the end of the children’s list.
Node.isSameNode(other)  
Return True if other refers to the same node as this node. This is especially useful for DOM implementations which use any sort of proxy architecture (because more than one object can refer to the same node).  Note This is based on a proposed DOM Level 3 API which is still in the “working draft” stage, but this particular interface appears uncontroversial. Changes from the W3C will not necessarily affect this method in the Python DOM interface (though any new W3C API for this would also be supported).
Node.lastChild  
The last child of the node, if there are any, or None. This is a read-only attribute.
Node.localName  
The part of the tagName following the colon if there is one, else the entire tagName. The value is a string.
Node.namespaceURI  
The namespace associated with the element name. This will be a string or None. This is a read-only attribute.
Node.nextSibling  
The node that immediately follows this one with the same parent. See also previousSibling. If this is the last child of the parent, this attribute will be None. This is a read-only attribute.
Node.nodeName  
This has a different meaning for each node type; see the DOM specification for details. You can always get the information you would get here from another property such as the tagName property for elements or the name property for attributes. For all node types, the value of this attribute will be either a string or None. This is a read-only attribute.
Node.nodeType  
An integer representing the node type. Symbolic constants for the types are on the Node object: ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE. This is a read-only attribute.
Node.nodeValue  
This has a different meaning for each node type; see the DOM specification for details. The situation is similar to that with nodeName. The value is a string or None.
Node.normalize()  
Join adjacent text nodes so that all stretches of text are stored as single Text instances. This simplifies processing text from a DOM tree for many applications.
Node.parentNode  
The parent of the current node, or None for the document node. The value is always a Node object or None. For Element nodes, this will be the parent element, except for the root element, in which case it will be the Document object. For Attr nodes, this is always None. This is a read-only attribute.
Node.prefix  
The part of the tagName preceding the colon if there is one, else the empty string. The value is a string, or None.
Node.previousSibling  
The node that immediately precedes this one with the same parent. For instance the element with an end-tag that comes just before the self element’s start-tag. Of course, XML documents are made up of more than just elements so the previous sibling could be text, a comment, or something else. If this node is the first child of the parent, this attribute will be None. This is a read-only attribute.
Node.removeChild(oldChild)  
Remove a child node. oldChild must be a child of this node; if not, ValueError is raised. oldChild is returned on success. If oldChild will not be used further, its unlink() method should be called.
Node.replaceChild(newChild, oldChild)  
Replace an existing node with a new node. It must be the case that oldChild is a child of this node; if not, ValueError is raised.
NodeList.item(i)  
Return the i’th item from the sequence, if there is one, or None. The index i is not allowed to be less than zero or greater than or equal to the length of the sequence.
exception xml.dom.NoModificationAllowedErr  
Raised on attempts to modify an object where modifications are not allowed (such as for read-only nodes).
exception xml.dom.NotFoundErr  
Exception when a node does not exist in the referenced context. For example, NamedNodeMap.removeNamedItem() will raise this if the node passed in does not exist in the map.
exception xml.dom.NotSupportedErr  
Raised when the implementation does not support the requested type of object or operation.
ProcessingInstruction.data  
The content of the processing instruction following the first whitespace character.
ProcessingInstruction.target  
The content of the processing instruction up to the first whitespace character. This is a read-only attribute.
xml.dom.pulldom.default_bufsize  
Default value for the bufsize parameter to parse(). The value of this variable can be changed before calling parse() and the new value will take effect.
class xml.dom.pulldom.DOMEventStream(stream, parser, bufsize)  
 Deprecated since version 3.8: Support for sequence protocol is deprecated.   
getEvent()  
Return a tuple containing event and the current node as xml.dom.minidom.Document if event equals START_DOCUMENT, xml.dom.minidom.Element if event equals START_ELEMENT or END_ELEMENT or xml.dom.minidom.Text if event equals CHARACTERS. The current node does not contain information about its children, unless expandNode() is called. 
  
expandNode(node)  
Expands all children of node into node. Example: from xml.dom import pulldom

xml = '<html><title>Foo</title> <p>Some text <div>and more</div></p> </html>'
doc = pulldom.parseString(xml)
for event, node in doc:
    if event == pulldom.START_ELEMENT and node.tagName == 'p':
        # Following statement only prints '<p/>'
        print(node.toxml())
        doc.expandNode(node)
        # Following statement prints node with all its children '<p>Some text <div>and more</div></p>'
        print(node.toxml())
 
  
reset()
expandNode(node)  
Expands all children of node into node. Example: from xml.dom import pulldom

xml = '<html><title>Foo</title> <p>Some text <div>and more</div></p> </html>'
doc = pulldom.parseString(xml)
for event, node in doc:
    if event == pulldom.START_ELEMENT and node.tagName == 'p':
        # Following statement only prints '<p/>'
        print(node.toxml())
        doc.expandNode(node)
        # Following statement prints node with all its children '<p>Some text <div>and more</div></p>'
        print(node.toxml())
getEvent()  
Return a tuple containing event and the current node as xml.dom.minidom.Document if event equals START_DOCUMENT, xml.dom.minidom.Element if event equals START_ELEMENT or END_ELEMENT or xml.dom.minidom.Text if event equals CHARACTERS. The current node does not contain information about its children, unless expandNode() is called.
xml.dom.pulldom.parse(stream_or_string, parser=None, bufsize=None)  
Return a DOMEventStream from the given input. stream_or_string may be either a file name, or a file-like object. parser, if given, must be an XMLReader object. This function will change the document handler of the parser and activate namespace support; other parser configuration (like setting an entity resolver) must have been done in advance.
xml.dom.pulldom.parseString(string, parser=None)  
Return a DOMEventStream that represents the (Unicode) string.
class xml.dom.pulldom.PullDom(documentFactory=None)  
Subclass of xml.sax.handler.ContentHandler.
class xml.dom.pulldom.SAX2DOM(documentFactory=None)  
Subclass of xml.sax.handler.ContentHandler.
xml.dom.registerDOMImplementation(name, factory)  
Register the factory function with the name name. The factory function should return an object which implements the DOMImplementation interface. The factory function can return the same object every time, or a new one for each call, as appropriate for the specific implementation (e.g. if that implementation supports some customization).
exception xml.dom.SyntaxErr  
Raised when an invalid or illegal string is specified.
exception xml.dom.WrongDocumentErr  
Raised when a node is inserted in a different document than it currently belongs to, and the implementation does not support migrating the node from one document to the other.
xml.dom.XHTML_NAMESPACE  
The URI of the XHTML namespace as defined by XHTML 1.0: The Extensible HyperText Markup Language (section 3.1.1).
xml.dom.XMLNS_NAMESPACE  
The namespace URI for namespace declarations, as defined by Document Object Model (DOM) Level 2 Core Specification (section 1.1.8).
xml.dom.XML_NAMESPACE  
The namespace URI associated with the reserved prefix xml, as defined by Namespaces in XML (section 4).
class xml.etree.ElementTree.C14NWriterTarget(write, *, with_comments=False, strip_text=False, rewrite_prefixes=False, qname_aware_tags=None, qname_aware_attrs=None, exclude_attrs=None, exclude_tags=None)  
A C14N 2.0 writer. Arguments are the same as for the canonicalize() function. This class does not build a tree but translates the callback events directly into a serialised form using the write function.  New in version 3.8.
xml.etree.ElementTree.canonicalize(xml_data=None, *, out=None, from_file=None, **options)  
C14N 2.0 transformation function. Canonicalization is a way to normalise XML output in a way that allows byte-by-byte comparisons and digital signatures. It reduced the freedom that XML serializers have and instead generates a more constrained XML representation. The main restrictions regard the placement of namespace declarations, the ordering of attributes, and ignorable whitespace. This function takes an XML data string (xml_data) or a file path or file-like object (from_file) as input, converts it to the canonical form, and writes it out using the out file(-like) object, if provided, or returns it as a text string if not. The output file receives text, not bytes. It should therefore be opened in text mode with utf-8 encoding. Typical uses: xml_data = "<root>...</root>"
print(canonicalize(xml_data))

with open("c14n_output.xml", mode='w', encoding='utf-8') as out_file:
    canonicalize(xml_data, out=out_file)

with open("c14n_output.xml", mode='w', encoding='utf-8') as out_file:
    canonicalize(from_file="inputfile.xml", out=out_file)
 The configuration options are as follows:  
with_comments: set to true to include comments (default: false) 
 
strip_text: set to true to strip whitespace before and after text content

(default: false)    
 
rewrite_prefixes: set to true to replace namespace prefixes by “n{number}”

(default: false)    
 
qname_aware_tags: a set of qname aware tag names in which prefixes

should be replaced in text content (default: empty)    
 
qname_aware_attrs: a set of qname aware attribute names in which prefixes

should be replaced in text content (default: empty)    
exclude_attrs: a set of attribute names that should not be serialised 
exclude_tags: a set of tag names that should not be serialised  In the option list above, “a set” refers to any collection or iterable of strings, no ordering is expected.  New in version 3.8.
xml.etree.ElementTree.Comment(text=None)  
Comment element factory. This factory function creates a special element that will be serialized as an XML comment by the standard serializer. The comment string can be either a bytestring or a Unicode string. text is a string containing the comment string. Returns an element instance representing a comment. Note that XMLParser skips over comments in the input instead of creating comment objects for them. An ElementTree will only contain comment nodes if they have been inserted into to the tree using one of the Element methods.
xml.etree.ElementTree.dump(elem)  
Writes an element tree or element structure to sys.stdout. This function should be used for debugging only. The exact output format is implementation dependent. In this version, it’s written as an ordinary XML file. elem is an element tree or an individual element.  Changed in version 3.8: The dump() function now preserves the attribute order specified by the user.
append(subelement)  
Adds the element subelement to the end of this element’s internal list of subelements. Raises TypeError if subelement is not an Element.
attrib  
A dictionary containing the element’s attributes. Note that while the attrib value is always a real mutable Python dictionary, an ElementTree implementation may choose to use another internal representation, and create the dictionary only if someone asks for it. To take advantage of such implementations, use the dictionary methods below whenever possible.
clear()  
Resets an element. This function removes all subelements, clears all attributes, and sets the text and tail attributes to None.
extend(subelements)  
Appends subelements from a sequence object with zero or more elements. Raises TypeError if a subelement is not an Element.  New in version 3.2.
find(match, namespaces=None)  
Finds the first subelement matching match. match may be a tag name or a path. Returns an element instance or None. namespaces is an optional mapping from namespace prefix to full name. Pass '' as prefix to move all unprefixed tag names in the expression into the given namespace.
findall(match, namespaces=None)  
Finds all matching subelements, by tag name or path. Returns a list containing all matching elements in document order. namespaces is an optional mapping from namespace prefix to full name. Pass '' as prefix to move all unprefixed tag names in the expression into the given namespace.
findtext(match, default=None, namespaces=None)  
Finds text for the first subelement matching match. match may be a tag name or a path. Returns the text content of the first matching element, or default if no element was found. Note that if the matching element has no text content an empty string is returned. namespaces is an optional mapping from namespace prefix to full name. Pass '' as prefix to move all unprefixed tag names in the expression into the given namespace.
get(key, default=None)  
Gets the element attribute named key. Returns the attribute value, or default if the attribute was not found.
insert(index, subelement)  
Inserts subelement at the given position in this element. Raises TypeError if subelement is not an Element.
items()  
Returns the element attributes as a sequence of (name, value) pairs. The attributes are returned in an arbitrary order.
iter(tag=None)  
Creates a tree iterator with the current element as the root. The iterator iterates over this element and all elements below it, in document (depth first) order. If tag is not None or '*', only elements whose tag equals tag are returned from the iterator. If the tree structure is modified during iteration, the result is undefined.  New in version 3.2.
iterfind(match, namespaces=None)  
Finds all matching subelements, by tag name or path. Returns an iterable yielding all matching elements in document order. namespaces is an optional mapping from namespace prefix to full name.  New in version 3.2.
itertext()  
Creates a text iterator. The iterator loops over this element and all subelements, in document order, and returns all inner text.  New in version 3.2.
keys()  
Returns the elements attribute names as a list. The names are returned in an arbitrary order.
makeelement(tag, attrib)  
Creates a new element object of the same type as this element. Do not call this method, use the SubElement() factory function instead.
remove(subelement)  
Removes subelement from the element. Unlike the find* methods this method compares elements based on the instance identity, not on tag value or contents.
tag  
A string identifying what kind of data this element represents (the element type, in other words).
text  
tail  
These attributes can be used to hold additional data associated with the element. Their values are usually strings but may be any application-specific object. If the element is created from an XML file, the text attribute holds either the text between the element’s start tag and its first child or end tag, or None, and the tail attribute holds either the text between the element’s end tag and the next tag, or None. For the XML data <a><b>1<c>2<d/>3</c></b>4</a>
 the a element has None for both text and tail attributes, the b element has text "1" and tail "4", the c element has text "2" and tail None, and the d element has text None and tail "3". To collect the inner text of an element, see itertext(), for example "".join(element.itertext()). Applications may store arbitrary objects in these attributes.
class xml.etree.ElementTree.ElementTree(element=None, file=None)  
ElementTree wrapper class. This class represents an entire element hierarchy, and adds some extra support for serialization to and from standard XML. element is the root element. The tree is initialized with the contents of the XML file if given.  
_setroot(element)  
Replaces the root element for this tree. This discards the current contents of the tree, and replaces it with the given element. Use with care. element is an element instance. 
  
find(match, namespaces=None)  
Same as Element.find(), starting at the root of the tree. 
  
findall(match, namespaces=None)  
Same as Element.findall(), starting at the root of the tree. 
  
findtext(match, default=None, namespaces=None)  
Same as Element.findtext(), starting at the root of the tree. 
  
getroot()  
Returns the root element for this tree. 
  
iter(tag=None)  
Creates and returns a tree iterator for the root element. The iterator loops over all elements in this tree, in section order. tag is the tag to look for (default is to return all elements). 
  
iterfind(match, namespaces=None)  
Same as Element.iterfind(), starting at the root of the tree.  New in version 3.2.  
  
parse(source, parser=None)  
Loads an external XML section into this element tree. source is a file name or file object. parser is an optional parser instance. If not given, the standard XMLParser parser is used. Returns the section root element. 
  
write(file, encoding="us-ascii", xml_declaration=None, default_namespace=None, method="xml", *, short_empty_elements=True)  
Writes the element tree to a file, as XML. file is a file name, or a file object opened for writing. encoding 1 is the output encoding (default is US-ASCII). xml_declaration controls if an XML declaration should be added to the file. Use False for never, True for always, None for only if not US-ASCII or UTF-8 or Unicode (default is None). default_namespace sets the default XML namespace (for “xmlns”). method is either "xml", "html" or "text" (default is "xml"). The keyword-only short_empty_elements parameter controls the formatting of elements that contain no content. If True (the default), they are emitted as a single self-closed tag, otherwise they are emitted as a pair of start/end tags. The output is either a string (str) or binary (bytes). This is controlled by the encoding argument. If encoding is "unicode", the output is a string; otherwise, it’s binary. Note that this may conflict with the type of file if it’s an open file object; make sure you do not try to write a string to a binary stream and vice versa.  New in version 3.4: The short_empty_elements parameter.   Changed in version 3.8: The write() method now preserves the attribute order specified by the user.
find(match, namespaces=None)  
Same as Element.find(), starting at the root of the tree.
findall(match, namespaces=None)  
Same as Element.findall(), starting at the root of the tree.
findtext(match, default=None, namespaces=None)  
Same as Element.findtext(), starting at the root of the tree.
iter(tag=None)  
Creates and returns a tree iterator for the root element. The iterator loops over all elements in this tree, in section order. tag is the tag to look for (default is to return all elements).
iterfind(match, namespaces=None)  
Same as Element.iterfind(), starting at the root of the tree.  New in version 3.2.
parse(source, parser=None)  
Loads an external XML section into this element tree. source is a file name or file object. parser is an optional parser instance. If not given, the standard XMLParser parser is used. Returns the section root element.