text
stringlengths
81
112k
parse an XML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the reader is closed or reset. def readFd(fd, URL, encoding, options): """parse an XML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the re...
parse an XML file from the filesystem or the network. def readFile(filename, encoding, options): """parse an XML file from the filesystem or the network. """ ret = libxml2mod.xmlReadFile(filename, encoding, options) if ret is None:raise treeError('xmlReadFile() failed') return xmlDoc(_obj=ret)
parse an XML in-memory document and build a tree. def readMemory(buffer, size, URL, encoding, options): """parse an XML in-memory document and build a tree. """ ret = libxml2mod.xmlReadMemory(buffer, size, URL, encoding, options) if ret is None:raise treeError('xmlReadMemory() failed') return xmlDoc(_o...
parse an XML in-memory document and build a tree. In the case the document is not Well Formed, a attempt to build a tree is tried anyway def recoverDoc(cur): """parse an XML in-memory document and build a tree. In the case the document is not Well Formed, a attempt to build a tree is trie...
parse an XML file and build a tree. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. In the case the document is not Well Formed, it attempts to build a tree anyway def recoverFile(filename): """parse an XML file and build a tree. Automatic...
parse an XML in-memory block and build a tree. In the case the document is not Well Formed, an attempt to build a tree is tried anyway def recoverMemory(buffer, size): """parse an XML in-memory block and build a tree. In the case the document is not Well Formed, an attempt to build a tree ...
append the char value in the array def copyChar(len, out, val): """append the char value in the array """ ret = libxml2mod.xmlCopyChar(len, out, val) return ret
Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. def createEntityParserCtxt(URL, ID, base): """Create a parser context for an external entity Automatic support for ZLIB/Compress compressed docu...
Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. def createFileParserCtxt(filename): """Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provi...
Create a parser context for an XML in-memory document. def createMemoryParserCtxt(buffer, size): """Create a parser context for an XML in-memory document. """ ret = libxml2mod.xmlCreateMemoryParserCtxt(buffer, size) if ret is None:raise parserError('xmlCreateMemoryParserCtxt() failed') return parserCtx...
Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses def createURLParserCtxt(filename, options): """Create a parser context for a file or URL content. Automatic suppo...
Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time. def htmlCreateFileParserCtxt(filename, encoding): """Create a parser context for a file content. Automatic support for ZLIB/Compress compressed doc...
Pops the top element name from the name stack def namePop(ctxt): """Pops the top element name from the name stack """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o ret = libxml2mod.namePop(ctxt__o) return ret
Pushes a new element name on top of the name stack def namePush(ctxt, value): """Pushes a new element name on top of the name stack """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o ret = libxml2mod.namePush(ctxt__o, value) return ret
Pops the top element node from the node stack def nodePop(ctxt): """Pops the top element node from the node stack """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o ret = libxml2mod.nodePop(ctxt__o) if ret is None:raise treeError('nodePop() failed') return xmlNode(_obj=ret)
Pushes a new element node on top of the node stack def nodePush(ctxt, value): """Pushes a new element node on top of the node stack """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o if value is None: value__o = None else: value__o = value._o ret = libxml2mod.nodePush(ctxt__o, value__o...
Create a libxml2 input buffer from a Python file def createInputBuffer(file, encoding): """Create a libxml2 input buffer from a Python file """ ret = libxml2mod.xmlCreateInputBuffer(file, encoding) if ret is None:raise treeError('xmlCreateInputBuffer() failed') return inputBuffer(_obj=ret)
Create a libxml2 output buffer from a Python file def createOutputBuffer(file, encoding): """Create a libxml2 output buffer from a Python file """ ret = libxml2mod.xmlCreateOutputBuffer(file, encoding) if ret is None:raise treeError('xmlCreateOutputBuffer() failed') return outputBuffer(_obj=ret)
Create a progressive XML parser context to build either an event flow if the SAX object is not None, or a DOM tree otherwise. def createPushParser(SAX, chunk, size, URI): """Create a progressive XML parser context to build either an event flow if the SAX object is not None, or a DOM tree ...
Create a progressive HTML parser context to build either an event flow if the SAX object is not None, or a DOM tree otherwise. def htmlCreatePushParser(SAX, chunk, size, URI): """Create a progressive HTML parser context to build either an event flow if the SAX object is not None, or a DOM tree ...
Create a new Node def newNode(name): """Create a new Node """ ret = libxml2mod.xmlNewNode(name) if ret is None:raise treeError('xmlNewNode() failed') return xmlNode(_obj=ret)
Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file. def relaxNGNewMemParserCtxt(buffer, size): """Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file. """ ret = libxml2mod.xmlRelaxNGNewMemParserCtxt...
Create an XML RelaxNGs parse context for that file/resource expected to contain an XML RelaxNGs file. def relaxNGNewParserCtxt(URL): """Create an XML RelaxNGs parse context for that file/resource expected to contain an XML RelaxNGs file. """ ret = libxml2mod.xmlRelaxNGNewParserCtxt(URL) if re...
Builds the QName @prefix:@ncname in @memory if there is enough space and prefix is not None nor empty, otherwise allocate a new string. If prefix is None or empty it returns ncname. def buildQName(ncname, prefix, memory, len): """Builds the QName @prefix:@ncname in @memory if there is enou...
Creation of a new node containing a comment. def newComment(content): """Creation of a new node containing a comment. """ ret = libxml2mod.xmlNewComment(content) if ret is None:raise treeError('xmlNewComment() failed') return xmlNode(_obj=ret)
Creates a new XML document def newDoc(version): """Creates a new XML document """ ret = libxml2mod.xmlNewDoc(version) if ret is None:raise treeError('xmlNewDoc() failed') return xmlDoc(_obj=ret)
Creation of a processing instruction element. Use xmlDocNewPI preferably to get string interning def newPI(name, content): """Creation of a processing instruction element. Use xmlDocNewPI preferably to get string interning """ ret = libxml2mod.xmlNewPI(name, content) if ret is None:raise tree...
Creation of a new text node. def newText(content): """Creation of a new text node. """ ret = libxml2mod.xmlNewText(content) if ret is None:raise treeError('xmlNewText() failed') return xmlNode(_obj=ret)
Creation of a new text node with an extra parameter for the content's length def newTextLen(content, len): """Creation of a new text node with an extra parameter for the content's length """ ret = libxml2mod.xmlNewTextLen(content, len) if ret is None:raise treeError('xmlNewTextLen() failed') ...
Unescaping routine, but does not check that the string is an URI. The output is a direct unsigned char translation of %XX values (no encoding) Note that the length of the result can only be smaller or same size as the input string. def URIUnescapeString(str, len, target): """Unescaping routine, ...
Parse an URI based on RFC 3986 URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] def parseURI(str): """Parse an URI based on RFC 3986 URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ] """ ret = libxml2mod.xmlParseURI(str) if ret is None:raise uriError('xmlParseURI(...
Parse an URI but allows to keep intact the original fragments. URI-reference = URI / relative-ref def parseURIRaw(str, raw): """Parse an URI but allows to keep intact the original fragments. URI-reference = URI / relative-ref """ ret = libxml2mod.xmlParseURIRaw(str, raw) if ret is None:rais...
Create an xmlTextReader structure fed with the resource at @URI def newTextReaderFilename(URI): """Create an xmlTextReader structure fed with the resource at @URI """ ret = libxml2mod.xmlNewTextReaderFilename(URI) if ret is None:raise treeError('xmlNewTextReaderFilename() failed') return ...
Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of xmlParserOption. def readerForDoc(cur, URL, encoding, options): """Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of xmlParserOption. """ ret =...
Create an xmltextReader for an XML from a file descriptor. The parsing flags @options are a combination of xmlParserOption. NOTE that the file descriptor will not be closed when the reader is closed or reset. def readerForFd(fd, URL, encoding, options): """Create an xmltextReader for an XML from...
parse an XML file from the filesystem or the network. The parsing flags @options are a combination of xmlParserOption. def readerForFile(filename, encoding, options): """parse an XML file from the filesystem or the network. The parsing flags @options are a combination of xmlParserOption. """ ret = ...
Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of xmlParserOption. def readerForMemory(buffer, size, URL, encoding, options): """Create an xmltextReader for an XML in-memory document. The parsing flags @options are a combination of xmlParserOption. "...
Parses a regular expression conforming to XML Schemas Part 2 Datatype Appendix F and builds an automata suitable for testing strings against that regular expression def regexpCompile(regexp): """Parses a regular expression conforming to XML Schemas Part 2 Datatype Appendix F and builds an automa...
Create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file. def schemaNewMemParserCtxt(buffer, size): """Create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file. """ ret = libxml2mod.xmlSchemaNewMemParserCtxt(buffe...
Create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file. def schemaNewParserCtxt(URL): """Create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file. """ ret = libxml2mod.xmlSchemaNewParserCtxt(URL) if ret is N...
Create a substring from a given UTF-8 string Note: positions are given in units of UTF-8 chars def UTF8Strsub(utf, start, len): """Create a substring from a given UTF-8 string Note: positions are given in units of UTF-8 chars """ ret = libxml2mod.xmlUTF8Strsub(utf, start, len) return ret
Pops the top XPath object from the value stack def valuePop(ctxt): """Pops the top XPath object from the value stack """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o ret = libxml2mod.valuePop(ctxt__o) return ret
Remove a namespace definition from a node. If href is None, remove all of the ns definitions on that node. The removed namespaces are returned as a linked list. Note: If any child nodes referred to the removed namespaces, they will be left with dangling links. You should call ...
Register an error handler that will be called back as f(arg,msg,severity,reserved). @reserved is currently always None. def setErrorHandler(self,f,arg): """Register an error handler that will be called back as f(arg,msg,severity,reserved). @reserved is currently al...
Register error and warning handlers for DTD validation. These will be called back as f(msg,arg) def setValidityErrorHandler(self, err_func, warn_func, arg=None): """ Register error and warning handlers for DTD validation. These will be called back as f(msg,arg) """ libxm...
Register error and warning handlers for Schema validation. These will be called back as f(msg,arg) def setValidityErrorHandler(self, err_func, warn_func, arg=None): """ Register error and warning handlers for Schema validation. These will be called back as f(msg,arg) """ ...
Register error and warning handlers for RelaxNG validation. These will be called back as f(msg,arg) def setValidityErrorHandler(self, err_func, warn_func, arg=None): """ Register error and warning handlers for RelaxNG validation. These will be called back as f(msg,arg) """ ...
Register an error handler that will be called back as f(arg,msg,severity,locator). def SetErrorHandler(self,f,arg): """Register an error handler that will be called back as f(arg,msg,severity,locator).""" if f is None: libxml2mod.xmlTextReaderSetErrorHandler(\ ...
Return (f,arg) as previously registered with setErrorHandler or (None,None). def GetErrorHandler(self): """Return (f,arg) as previously registered with setErrorHandler or (None,None).""" f,arg = libxml2mod.xmlTextReaderGetErrorHandler(self._o) if f is None: ret...
Get the namespace of a node def ns(self): """Get the namespace of a node """ ret = libxml2mod.xmlNodeGetNs(self._o) if ret is None:return None __tmp = xmlNs(_obj=ret) return __tmp
Get the namespace of a node def nsDefs(self): """Get the namespace of a node """ ret = libxml2mod.xmlNodeGetNsDefs(self._o) if ret is None:return None __tmp = xmlNs(_obj=ret) return __tmp
Dumps debug information for the element node, it is recursive def debugDumpNode(self, output, depth): """Dumps debug information for the element node, it is recursive """ libxml2mod.xmlDebugDumpNode(output, self._o, depth)
Dumps debug information for the list of element node, it is recursive def debugDumpNodeList(self, output, depth): """Dumps debug information for the list of element node, it is recursive """ libxml2mod.xmlDebugDumpNodeList(output, self._o, depth)
Dumps debug information for the element node, it is not recursive def debugDumpOneNode(self, output, depth): """Dumps debug information for the element node, it is not recursive """ libxml2mod.xmlDebugDumpOneNode(output, self._o, depth)
Add a new node to @parent, at the end of the child (or property) list merging adjacent TEXT nodes (in which case @cur is freed) If the new node is ATTRIBUTE, it is added into properties instead of children. If there is an attribute with equal name, it is first destroyed. def ad...
Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (@cur may be freed) def addChildList(self, cur): """Add a list of node at the end of the child list of the parent merging adjacent TEXT nodes (@cur may be freed) """ if cur is None: cur__o = ...
Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported. def addContentLen(self, content, len): """Append the extra substring ...
Add a new node @elem as the next sibling of @cur If the new node was already inserted in a document it is first unlinked from its existing context. As a result of text merging @elem may be freed. If the new node is ATTRIBUTE, it is added into properties instead of children. If th...
Add a new node @elem as the previous sibling of @cur merging adjacent TEXT nodes (@elem may be freed) If the new node was already inserted in a document it is first unlinked from its existing context. If the new node is ATTRIBUTE, it is added into properties instead of children. ...
Add a new element @elem to the list of siblings of @cur merging adjacent TEXT nodes (@elem may be freed) If the new element was already inserted in a document it is first unlinked from its existing context. def addSibling(self, elem): """Add a new element @elem to the list of sib...
Do a copy of the node. def copyNode(self, extended): """Do a copy of the node. """ ret = libxml2mod.xmlCopyNode(self._o, extended) if ret is None:raise treeError('xmlCopyNode() failed') __tmp = xmlNode(_obj=ret) return __tmp
Do a recursive copy of the node list. Use xmlDocCopyNodeList() if possible to ensure string interning. def copyNodeList(self): """Do a recursive copy of the node list. Use xmlDocCopyNodeList() if possible to ensure string interning. """ ret = libxml2mod.xmlCopyNodeList(self._o) ...
Do a copy of the attribute. def copyProp(self, cur): """Do a copy of the attribute. """ if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlCopyProp(self._o, cur__o) if ret is None:raise treeError('xmlCopyProp() failed') __tmp = xmlAttr(_obj=ret) ...
Do a copy of an attribute list. def copyPropList(self, cur): """Do a copy of an attribute list. """ if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlCopyPropList(self._o, cur__o) if ret is None:raise treeError('xmlCopyPropList() failed') __tmp = xm...
Do a copy of the node to a given document. def docCopyNode(self, doc, extended): """Do a copy of the node to a given document. """ if doc is None: doc__o = None else: doc__o = doc._o ret = libxml2mod.xmlDocCopyNode(self._o, doc__o, extended) if ret is None:raise treeError('xmlDo...
Do a recursive copy of the node list. def docCopyNodeList(self, doc): """Do a recursive copy of the node list. """ if doc is None: doc__o = None else: doc__o = doc._o ret = libxml2mod.xmlDocCopyNodeList(doc__o, self._o) if ret is None:raise treeError('xmlDocCopyNodeList() failed...
Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...). def docSetRootElement(self, doc): """Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...). """ if doc is None: doc__o = N...
Finds the first child node of that element which is a Element node Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. def firstElementChild(self): ...
Searches for the BASE URL. The code should work on both XML and HTML document even if base mechanisms are completely different. It returns the base as defined in RFC 2396 sections 5.1.1. Base URI within Document Content and 5.1.2. Base URI from the Encapsulating Entity However it...
Search for an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. Note that a ...
Search an attribute associated to a node This function also looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. def hasProp(self, name): """Search an attribute associated to a node This function also looks in DTD attribu...
Search the last child of a node. def lastChild(self): """Search the last child of a node. """ ret = libxml2mod.xmlGetLastChild(self._o) if ret is None:raise treeError('xmlGetLastChild() failed') __tmp = xmlNode(_obj=ret) return __tmp
Finds the last child node of that element which is a Element node Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. def lastElementChild(self): ...
Builds the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs, contrary to xmlNodeListGetString() this function doesn't do any character encoding handling. def listGetRawString(self, doc, inLine): """Builds the string equivalent to the text con...
Build the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs def listGetString(self, doc, inLine): """Build the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs """ if doc is None: doc__o = None else...
Creation of a new child element, added at the end of @parent children list. @ns and @content parameters are optional (None). If @ns is None, the newly created element inherits the namespace of @parent. If @content is non None, a child list containing the TEXTs and ENTITY_REFs nod...
Creation of a new Namespace. This function will refuse to create a namespace with a similar prefix than an existing one present on this node. We use href==None in the case of an element creation where the namespace was not defined. def newNs(self, href, prefix): """Creation of a ...
Create a new property tagged with a namespace and carried by a node. def newNsProp(self, ns, name, value): """Create a new property tagged with a namespace and carried by a node. """ if ns is None: ns__o = None else: ns__o = ns._o ret = libxml2mod.xmlNewNsProp(self...
Create a new property tagged with a namespace and carried by a node. def newNsPropEatName(self, ns, name, value): """Create a new property tagged with a namespace and carried by a node. """ if ns is None: ns__o = None else: ns__o = ns._o ret = libxml2mod.xmlNewNsPr...
Create a new property carried by a node. def newProp(self, name, value): """Create a new property carried by a node. """ ret = libxml2mod.xmlNewProp(self._o, name, value) if ret is None:raise treeError('xmlNewProp() failed') __tmp = xmlAttr(_obj=ret) return __tmp
Creation of a new child element, added at the end of @parent children list. @ns and @content parameters are optional (None). If @ns is None, the newly created element inherits the namespace of @parent. If @content is non None, a child TEXT node will be created containing the stri...
Finds the first closest next sibling of the node which is an element node. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. def nextElementSibling(se...
Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. This function is similar to xmlGetProp except it will acc...
Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified. This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned...
Finds the first closest previous sibling of the node which is an element node. Note the handling of entities references is different than in the W3C DOM element traversal spec since we don't have back reference from entities content to entities references. def previousElementSi...
Search and get the value of an attribute associated to a node This does the entity substitution. This function looks in DTD attribute declaration for #FIXED or default declaration values unless DTD use has been turned off. NOTE: this function acts independently of namespaces ...
This function checks that all the namespaces declared within the given tree are properly declared. This is needed for example after Copy or Cut and then paste operations. The subtree may still hold pointers to namespace declarations outside the subtree or invalid/masked. As much ...
Unlink the old node from its current context, prune the new one at the same place. If @cur was already inserted in a document it is first unlinked from its existing context. def replaceNode(self, cur): """Unlink the old node from its current context, prune the new one at the same...
Search a Ns registered under a given name space for a document. recurse on the parents until it finds the defined namespace or return None otherwise. @nameSpace can be None, this is a search for the default namespace. We don't allow to cross entities boundaries. If you don't decl...
Search a Ns aliasing a given URI. Recurse on the parents until it finds the defined namespace or return None otherwise. def searchNsByHref(self, doc, href): """Search a Ns aliasing a given URI. Recurse on the parents until it finds the defined namespace or return None ...
Replace the content of a node. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references, but XML special chars need to be escaped first by using xmlEncodeEntitiesReentrant() resp. xmlEncodeSpecialChars(). def setContentLen(self, content, len): """Repl...
update all nodes in the list to point to the right document def setListDoc(self, doc): """update all nodes in the list to point to the right document """ if doc is None: doc__o = None else: doc__o = doc._o libxml2mod.xmlSetListDoc(self._o, doc__o)
Associate a namespace to a node, a posteriori. def setNs(self, ns): """Associate a namespace to a node, a posteriori. """ if ns is None: ns__o = None else: ns__o = ns._o libxml2mod.xmlSetNs(self._o, ns__o)
Set (or reset) an attribute carried by a node. The ns structure must be in scope, this is not checked def setNsProp(self, ns, name, value): """Set (or reset) an attribute carried by a node. The ns structure must be in scope, this is not checked """ if ns is None: ns__o = None ...
Set (or reset) an attribute carried by a node. If @name has a prefix, then the corresponding namespace-binding will be used, if in scope; it is an error it there's no such ns-binding for the prefix in scope. def setProp(self, name, value): """Set (or reset) an attribute carried b...
update all nodes under the tree to point to the right document def setTreeDoc(self, doc): """update all nodes under the tree to point to the right document """ if doc is None: doc__o = None else: doc__o = doc._o libxml2mod.xmlSetTreeDoc(self._o, doc__o)
Concat the given string at the end of the existing node content def textConcat(self, content, len): """Concat the given string at the end of the existing node content """ ret = libxml2mod.xmlTextConcat(self._o, content, len) return ret
Merge two text nodes into one def textMerge(self, second): """Merge two text nodes into one """ if second is None: second__o = None else: second__o = second._o ret = libxml2mod.xmlTextMerge(self._o, second__o) if ret is None:raise treeError('xmlTextMerge() failed') __tmp...
Remove an attribute carried by a node. def unsetNsProp(self, ns, name): """Remove an attribute carried by a node. """ if ns is None: ns__o = None else: ns__o = ns._o ret = libxml2mod.xmlUnsetNsProp(self._o, ns__o, name) return ret
Remove an attribute carried by a node. This handles only attributes in no namespace. def unsetProp(self, name): """Remove an attribute carried by a node. This handles only attributes in no namespace. """ ret = libxml2mod.xmlUnsetProp(self._o, name) return ret