doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
Node.firstChild The first child of the node, if there are any, or None. This is a read-only attribute.
python.library.xml.dom#xml.dom.Node.firstChild
Node.hasAttributes() Return True if the node has any attributes.
python.library.xml.dom#xml.dom.Node.hasAttributes
Node.hasChildNodes() Return True if the node has any child nodes.
python.library.xml.dom#xml.dom.Node.hasChildNodes
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.
python.library.xml.dom#xml.dom.Node.insertBefore
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...
python.library.xml.dom#xml.dom.Node.isSameNode
Node.lastChild The last child of the node, if there are any, or None. This is a read-only attribute.
python.library.xml.dom#xml.dom.Node.lastChild
Node.localName The part of the tagName following the colon if there is one, else the entire tagName. The value is a string.
python.library.xml.dom#xml.dom.Node.localName
Node.namespaceURI The namespace associated with the element name. This will be a string or None. This is a read-only attribute.
python.library.xml.dom#xml.dom.Node.namespaceURI
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.
python.library.xml.dom#xml.dom.Node.nextSibling
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 eithe...
python.library.xml.dom#xml.dom.Node.nodeName
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.
python.library.xml.dom#xml.dom.Node.nodeType
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.
python.library.xml.dom#xml.dom.Node.nodeValue
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.
python.library.xml.dom#xml.dom.Node.normalize
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.
python.library.xml.dom#xml.dom.Node.parentNode
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.
python.library.xml.dom#xml.dom.Node.prefix
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 t...
python.library.xml.dom#xml.dom.Node.previousSibling
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.
python.library.xml.dom#xml.dom.Node.removeChild
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.
python.library.xml.dom#xml.dom.Node.replaceChild
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.
python.library.xml.dom#xml.dom.NodeList.item
NodeList.length The number of nodes in the sequence.
python.library.xml.dom#xml.dom.NodeList.length
exception xml.dom.NoModificationAllowedErr Raised on attempts to modify an object where modifications are not allowed (such as for read-only nodes).
python.library.xml.dom#xml.dom.NoModificationAllowedErr
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.
python.library.xml.dom#xml.dom.NotFoundErr
exception xml.dom.NotSupportedErr Raised when the implementation does not support the requested type of object or operation.
python.library.xml.dom#xml.dom.NotSupportedErr
ProcessingInstruction.data The content of the processing instruction following the first whitespace character.
python.library.xml.dom#xml.dom.ProcessingInstruction.data
ProcessingInstruction.target The content of the processing instruction up to the first whitespace character. This is a read-only attribute.
python.library.xml.dom#xml.dom.ProcessingInstruction.target
xml.dom.pulldom — Support for building partial DOM trees Source code: Lib/xml/dom/pulldom.py The xml.dom.pulldom module provides a “pull parser” which can also be asked to produce DOM-accessible fragments of the document where necessary. The basic concept involves pulling “events” from a stream of incoming XML and proc...
python.library.xml.dom.pulldom
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.
python.library.xml.dom.pulldom#xml.dom.pulldom.default_bufsize
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_ELEME...
python.library.xml.dom.pulldom#xml.dom.pulldom.DOMEventStream
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 stateme...
python.library.xml.dom.pulldom#xml.dom.pulldom.DOMEventStream.expandNode
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 ...
python.library.xml.dom.pulldom#xml.dom.pulldom.DOMEventStream.getEvent
reset()
python.library.xml.dom.pulldom#xml.dom.pulldom.DOMEventStream.reset
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...
python.library.xml.dom.pulldom#xml.dom.pulldom.parse
xml.dom.pulldom.parseString(string, parser=None) Return a DOMEventStream that represents the (Unicode) string.
python.library.xml.dom.pulldom#xml.dom.pulldom.parseString
class xml.dom.pulldom.PullDom(documentFactory=None) Subclass of xml.sax.handler.ContentHandler.
python.library.xml.dom.pulldom#xml.dom.pulldom.PullDom
class xml.dom.pulldom.SAX2DOM(documentFactory=None) Subclass of xml.sax.handler.ContentHandler.
python.library.xml.dom.pulldom#xml.dom.pulldom.SAX2DOM
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 impl...
python.library.xml.dom#xml.dom.registerDOMImplementation
exception xml.dom.SyntaxErr Raised when an invalid or illegal string is specified.
python.library.xml.dom#xml.dom.SyntaxErr
Text.data The content of the text node as a string.
python.library.xml.dom#xml.dom.Text.data
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.
python.library.xml.dom#xml.dom.WrongDocumentErr
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).
python.library.xml.dom#xml.dom.XHTML_NAMESPACE
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).
python.library.xml.dom#xml.dom.XMLNS_NAMESPACE
xml.dom.XML_NAMESPACE The namespace URI associated with the reserved prefix xml, as defined by Namespaces in XML (section 4).
python.library.xml.dom#xml.dom.XML_NAMESPACE
xml.etree.ElementTree — The ElementTree XML API Source code: Lib/xml/etree/ElementTree.py The xml.etree.ElementTree module implements a simple and efficient API for parsing and creating XML data. Changed in version 3.3: This module will use a fast implementation whenever available. Deprecated since version 3.3: The ...
python.library.xml.etree.elementtree
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...
python.library.xml.etree.elementtree#xml.etree.ElementTree.C14NWriterTarget
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 m...
python.library.xml.etree.elementtree#xml.etree.ElementTree.canonicalize
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 ...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Comment
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...
python.library.xml.etree.elementtree#xml.etree.ElementTree.dump
class xml.etree.ElementTree.Element(tag, attrib={}, **extra) Element class. This class defines the Element interface, and provides a reference implementation of this interface. The element name, attribute names, and attribute values can be either bytestrings or Unicode strings. tag is the element name. attrib is an o...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.append
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 t...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.attrib
clear() Resets an element. This function removes all subelements, clears all attributes, and sets the text and tail attributes to None.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.clear
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.extend
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.find
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.findall
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. namespace...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.findtext
get(key, default=None) Gets the element attribute named key. Returns the attribute value, or default if the attribute was not found.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.get
insert(index, subelement) Inserts subelement at the given position in this element. Raises TypeError if subelement is not an Element.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.insert
items() Returns the element attributes as a sequence of (name, value) pairs. The attributes are returned in an arbitrary order.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.items
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 iterat...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.iter
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.iterfind
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.itertext
keys() Returns the elements attribute names as a list. The names are returned in an arbitrary order.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.keys
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.makeelement
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.remove
set(key, value) Set the attribute key on the element to value.
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.set
tag A string identifying what kind of data this element represents (the element type, in other words).
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.tag
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...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.tail
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...
python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.text
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. _set...
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree
find(match, namespaces=None) Same as Element.find(), starting at the root of the tree.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.find
findall(match, namespaces=None) Same as Element.findall(), starting at the root of the tree.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.findall
findtext(match, default=None, namespaces=None) Same as Element.findtext(), starting at the root of the tree.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.findtext
getroot() Returns the root element for this tree.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.getroot
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).
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.iter
iterfind(match, namespaces=None) Same as Element.iterfind(), starting at the root of the tree. New in version 3.2.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.iterfind
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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.parse
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 de...
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree.write
_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.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ElementTree._setroot
xml.etree.ElementTree.fromstring(text, parser=None) Parses an XML section from a string constant. Same as XML(). text is a string containing XML data. parser is an optional parser instance. If not given, the standard XMLParser parser is used. Returns an Element instance.
python.library.xml.etree.elementtree#xml.etree.ElementTree.fromstring
xml.etree.ElementTree.fromstringlist(sequence, parser=None) Parses an XML document from a sequence of string fragments. sequence is a list or other sequence containing XML data fragments. parser is an optional parser instance. If not given, the standard XMLParser parser is used. Returns an Element instance. New in v...
python.library.xml.etree.elementtree#xml.etree.ElementTree.fromstringlist
xml.etree.ElementTree.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 ...
python.library.xml.etree.elementtree#xml.etree.ElementTree.indent
xml.etree.ElementTree.iselement(element) Check if an object appears to be a valid element object. element is an element instance. Return True if this is an element object.
python.library.xml.etree.elementtree#xml.etree.ElementTree.iselement
xml.etree.ElementTree.iterparse(source, events=None, parser=None) Parses an XML section into an element tree incrementally, and reports what’s going on to the user. source is a filename or file object containing XML data. events is a sequence of events to report back. The supported events are the strings "start", "en...
python.library.xml.etree.elementtree#xml.etree.ElementTree.iterparse
xml.etree.ElementTree.parse(source, parser=None) Parses an XML section into an element tree. source is a filename or file object containing XML data. parser is an optional parser instance. If not given, the standard XMLParser parser is used. Returns an ElementTree instance.
python.library.xml.etree.elementtree#xml.etree.ElementTree.parse
class xml.etree.ElementTree.ParseError XML parse error, raised by the various parsing methods in this module when parsing fails. The string representation of an instance of this exception will contain a user-friendly error message. In addition, it will have the following attributes available: code A numeric error...
python.library.xml.etree.elementtree#xml.etree.ElementTree.ParseError
code A numeric error code from the expat parser. See the documentation of xml.parsers.expat for the list of error codes and their meanings.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ParseError.code
position A tuple of line, column numbers, specifying where the error occurred.
python.library.xml.etree.elementtree#xml.etree.ElementTree.ParseError.position
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, ...
python.library.xml.etree.elementtree#xml.etree.ElementTree.ProcessingInstruction
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 i...
python.library.xml.etree.elementtree#xml.etree.ElementTree.QName
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...
python.library.xml.etree.elementtree#xml.etree.ElementTree.register_namespace
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 subelem...
python.library.xml.etree.elementtree#xml.etree.ElementTree.SubElement
xml.etree.ElementTree.tostring(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)...
python.library.xml.etree.elementtree#xml.etree.ElementTree.tostring
xml.etree.ElementTree.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-AS...
python.library.xml.etree.elementtree#xml.etree.ElementTree.tostringlist
class xml.etree.ElementTree.TreeBuilder(element_factory=None, *, comment_factory=None, pi_factory=None, insert_comments=False, insert_pis=False) Generic element structure builder. This builder converts a sequence of start, data, end, comment and pi method calls to a well-formed element structure. You can use this cla...
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder
close() Flushes the builder buffers, and returns the toplevel document element. Returns an Element instance.
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder.close
comment(text) Creates a comment with the given text. If insert_comments is true, this will also add it to the tree. New in version 3.8.
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder.comment
data(data) Adds text to the current element. data is a string. This should be either a bytestring, or a Unicode string.
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder.data
doctype(name, pubid, system) Handles a doctype declaration. name is the doctype name. pubid is the public identifier. system is the system identifier. This method does not exist on the default TreeBuilder class. New in version 3.2.
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder.doctype
end(tag) Closes the current element. tag is the element name. Returns the closed element.
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder.end
end_ns(prefix) Is called after the end() callback of an element that declared a namespace prefix mapping, with the name of the prefix that went out of scope. New in version 3.8.
python.library.xml.etree.elementtree#xml.etree.ElementTree.TreeBuilder.end_ns