Module libxml2 :: Class xmlNode
[hide private]
[frames] | no frames]

Class xmlNode

source code

xmlCore --+
          |
         xmlNode
Known Subclasses:
xmlAttr, xmlAttribute, xmlDoc, xmlDtd, xmlElement, xmlEntity, xmlNs

Instance Methods [hide private]
 
__init__(self, _obj=None) source code
 
__repr__(self) source code
 
ns(self)
Get the namespace of a node
source code
 
nsDefs(self)
Get the namespace of a node
source code
 
debugDumpNode(self, output, depth)
Dumps debug information for the element node, it is recursive
source code
 
debugDumpNodeList(self, output, depth)
Dumps debug information for the list of element node, it is recursive
source code
 
debugDumpOneNode(self, output, depth)
Dumps debug information for the element node, it is not recursive
source code
 
lsCountNode(self)
Count the children of @node.
source code
 
lsOneNode(self, output)
Dump to @output the type and name of @node.
source code
 
shellPrintNode(self)
Print node to the output FILE
source code
 
addChild(self, cur)
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.
source code
 
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)
source code
 
addContent(self, content)
Append the extra substring to the node content.
source code
 
addContentLen(self, content, len)
Append the extra substring to the node content.
source code
 
addNextSibling(self, elem)
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.
source code
 
addPrevSibling(self, elem)
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.
source code
 
addSibling(self, elem)
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.
source code
 
copyNode(self, extended)
Do a copy of the node.
source code
 
copyNodeList(self)
Do a recursive copy of the node list.
source code
 
copyProp(self, cur)
Do a copy of the attribute.
source code
 
copyPropList(self, cur)
Do a copy of an attribute list.
source code
 
docCopyNode(self, doc, extended)
Do a copy of the node to a given document.
source code
 
docCopyNodeList(self, doc)
Do a recursive copy of the node list.
source code
 
docSetRootElement(self, doc)
Set the root element of the document (doc->children is a list containing possibly comments, PIs, etc ...).
source code
 
freeNode(self)
Free a node, this is a recursive behaviour, all the children are freed too.
source code
 
freeNodeList(self)
Free a node and all its siblings, this is a recursive behaviour, all the children are freed too.
source code
 
getBase(self, doc)
Searches for the BASE URL.
source code
 
getContent(self)
Read the value of a node, this can be either the text carried directly by this node if it's a TEXT node or the aggregate string of the values carried by this node child's (TEXT and ENTITY_REF).
source code
 
getLang(self)
Searches the language of a node, i.e.
source code
 
getSpacePreserve(self)
Searches the space preserving behaviour of a node, i.e.
source code
 
hasNsProp(self, name, nameSpace)
Search for an attribute associated to a node This attribute has to be anchored in the namespace specified.
source code
 
hasProp(self, name)
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.
source code
 
isBlankNode(self)
Checks whether this node is an empty or whitespace only (and possibly ignorable) text-node.
source code
 
isText(self)
Is this node a Text node ?
source code
 
lastChild(self)
Search the last child of a node.
source code
 
lineNo(self)
Get line number of @node.
source code
 
listGetRawString(self, doc, inLine)
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.
source code
 
listGetString(self, doc, inLine)
Build the string equivalent to the text contained in the Node list made of TEXTs and ENTITY_REFs
source code
 
newChild(self, ns, name, content)
Creation of a new child element, added at the end of @parent children list.
source code
 
newNs(self, href, prefix)
Creation of a new Namespace.
source code
 
newNsProp(self, ns, name, value)
Create a new property tagged with a namespace and carried by a node.
source code
 
newNsPropEatName(self, ns, name, value)
Create a new property tagged with a namespace and carried by a node.
source code
 
newProp(self, name, value)
Create a new property carried by a node.
source code
 
newTextChild(self, ns, name, content)
Creation of a new child element, added at the end of @parent children list.
source code
 
noNsProp(self, name)
Search and get the value of an attribute associated to a node This does the entity substitution.
source code
 
nodePath(self)
Build a structure based Path for the given node
source code
 
nsProp(self, name, nameSpace)
Search and get the value of an attribute associated to a node This attribute has to be anchored in the namespace specified.
source code
 
prop(self, name)
Search and get the value of an attribute associated to a node This does the entity substitution.
source code
 
reconciliateNs(self, doc)
This function checks that all the namespaces declared within the given tree are properly declared.
source code
 
replaceNode(self, cur)
Unlink the old node from its current context, prune the new one at the same place.
source code
 
searchNs(self, doc, nameSpace)
Search a Ns registered under a given name space for a document.
source code
 
searchNsByHref(self, doc, href)
Search a Ns aliasing a given URI.
source code
 
setBase(self, uri)
Set (or reset) the base URI of a node, i.e.
source code
 
setContent(self, content)
Replace the content of a node.
source code
 
setContentLen(self, content, len)
Replace the content of a node.
source code
 
setLang(self, lang)
Set the language of a node, i.e.
source code
 
setListDoc(self, doc)
update all nodes in the list to point to the right document
source code
 
setName(self, name)
Set (or reset) the name of a node.
source code
 
setNs(self, ns)
Associate a namespace to a node, a posteriori.
source code
 
setNsProp(self, ns, name, value)
Set (or reset) an attribute carried by a node.
source code
 
setProp(self, name, value)
Set (or reset) an attribute carried by a node.
source code
 
setSpacePreserve(self, val)
Set (or reset) the space preserving behaviour of a node, i.e.
source code
 
setTreeDoc(self, doc)
update all nodes under the tree to point to the right document
source code
 
textConcat(self, content, len)
Concat the given string at the end of the existing node content
source code
 
textMerge(self, second)
Merge two text nodes into one
source code
 
unlinkNode(self)
Unlink a node from it's current context, the node is not freed
source code
 
unsetNsProp(self, ns, name)
Remove an attribute carried by a node.
source code
 
unsetProp(self, name)
Remove an attribute carried by a node.
source code
 
isID(self, doc, attr)
Determine whether an attribute is of type ID.
source code
 
isRef(self, doc, attr)
Determine whether an attribute is of type Ref.
source code
 
validNormalizeAttributeValue(self, doc, name, value)
Does the validation related extra step of the normalization of attribute values: If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by single space (#x20) character.
source code
 
xincludeProcessTree(self)
Implement the XInclude substitution for the given subtree
source code
 
xincludeProcessTreeFlags(self, flags)
Implement the XInclude substitution for the given subtree
source code
 
schemaValidateOneElement(self, ctxt) source code
 
xpathCastNodeToNumber(self)
Converts a node to its number value
source code
 
xpathCastNodeToString(self)
Converts a node to its string value.
source code
 
xpathCmpNodes(self, node2)
Compare two nodes w.r.t document order
source code
 
xpathNewNodeSet(self)
Create a new xmlXPathObjectPtr of type NodeSet and initialize it with the single Node @val
source code
 
xpathNewValueTree(self)
Create a new xmlXPathObjectPtr of type Value Tree (XSLT) and initialize it with the tree root @val
source code
 
xpathNextAncestor(self, ctxt)
Traversal function for the "ancestor" direction the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; the nodes are ordered in reverse document order; thus the parent is the first node on the axis, and the parent's parent is the second node on the axis
source code
 
xpathNextAncestorOrSelf(self, ctxt)
Traversal function for the "ancestor-or-self" direction he ancestor-or-self axis contains the context node and ancestors of the context node in reverse document order; thus the context node is the first node on the axis, and the context node's parent the second; parent here is defined the same as with the parent axis.
source code
 
xpathNextAttribute(self, ctxt)
Traversal function for the "attribute" direction TODO: support DTD inherited default attributes
source code
 
xpathNextChild(self, ctxt)
Traversal function for the "child" direction The child axis contains the children of the context node in document order.
source code
 
xpathNextDescendant(self, ctxt)
Traversal function for the "descendant" direction the descendant axis contains the descendants of the context node in document order; a descendant is a child or a child of a child and so on.
source code
 
xpathNextDescendantOrSelf(self, ctxt)
Traversal function for the "descendant-or-self" direction the descendant-or-self axis contains the context node and the descendants of the context node in document order; thus the context node is the first node on the axis, and the first child of the context node is the second node on the axis
source code
 
xpathNextFollowing(self, ctxt)
Traversal function for the "following" direction The following axis contains all nodes in the same document as the context node that are after the context node in document order, excluding any descendants and excluding attribute nodes and namespace nodes; the nodes are ordered in document order
source code
 
xpathNextFollowingSibling(self, ctxt)
Traversal function for the "following-sibling" direction The following-sibling axis contains the following siblings of the context node in document order.
source code
 
xpathNextNamespace(self, ctxt)
Traversal function for the "namespace" direction the namespace axis contains the namespace nodes of the context node; the order of nodes on this axis is implementation-defined; the axis will be empty unless the context node is an element We keep the XML namespace node at the end of the list.
source code
 
xpathNextParent(self, ctxt)
Traversal function for the "parent" direction The parent axis contains the parent of the context node, if there is one.
source code
 
xpathNextPreceding(self, ctxt)
Traversal function for the "preceding" direction the preceding axis contains all nodes in the same document as the context node that are before the context node in document order, excluding any ancestors and excluding attribute nodes and namespace nodes; the nodes are ordered in reverse document order
source code
 
xpathNextPrecedingSibling(self, ctxt)
Traversal function for the "preceding-sibling" direction The preceding-sibling axis contains the preceding siblings of the context node in reverse document order; the first preceding sibling is first on the axis; the sibling preceding that node is the second on the axis and so on.
source code
 
xpathNextSelf(self, ctxt)
Traversal function for the "self" direction The self axis contains just the context node itself
source code
 
xpointerNewCollapsedRange(self)
Create a new xmlXPathObjectPtr of type range using a single nodes
source code
 
xpointerNewContext(self, doc, origin)
Create a new XPointer context
source code
 
xpointerNewLocationSetNodes(self, end)
Create a new xmlXPathObjectPtr of type LocationSet and initialize it with the single range made of the two nodes @start and @end
source code
 
xpointerNewRange(self, startindex, end, endindex)
Create a new xmlXPathObjectPtr of type range
source code
 
xpointerNewRangeNodes(self, end)
Create a new xmlXPathObjectPtr of type range using 2 nodes
source code

Inherited from xmlCore: __eq__, __getattr__, __hash__, __iter__, __ne__, __str__, c14nMemory, c14nSaveTo, free, get_children, get_content, get_doc, get_last, get_name, get_next, get_parent, get_prev, get_properties, get_type, removeNsDef, saveTo, serialize, walk_breadth_first, walk_depth_first, xpathEval, xpathEval2

Properties [hide private]

Inherited from xmlCore: children, content, doc, last, name, next, parent, prev, properties, type

Method Details [hide private]

__init__(self, _obj=None)
(Constructor)

source code 
Overrides: xmlCore.__init__

addChild(self, cur)

source code 
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.

addContent(self, content)

source code 
Append the extra substring to the node content. NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be raw text, so unescaped XML special chars are allowed, entity references are not supported.

addContentLen(self, content, len)

source code 
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.

addNextSibling(self, elem)

source code 
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 there is an attribute with equal name, it is first destroyed.

addPrevSibling(self, elem)

source code 
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. If there is an attribute with equal name, it is first destroyed.

copyNodeList(self)

source code 
Do a recursive copy of the node list. Use xmlDocCopyNodeList() if possible to ensure string interning.

freeNode(self)

source code 
Free a node, this is a recursive behaviour, all the children are freed too. This doesn't unlink the child from the list, use xmlUnlinkNode() first.

getBase(self, doc)

source code 
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
does not return the document base (5.1.3), use
xmlDocumentGetBase() for this 

getContent(self)

source code 
Read the value of a node, this can be either the text carried directly by this node if it's a TEXT node or the aggregate string of the values carried by this node child's (TEXT and ENTITY_REF). Entity references are substituted.
Overrides: xmlCore.get_content

getLang(self)

source code 
Searches the language of a node, i.e. the values of the xml:lang attribute or the one carried by the nearest ancestor.

getSpacePreserve(self)

source code 
Searches the space preserving behaviour of a node, i.e. the values of the xml:space attribute or the one carried by the nearest ancestor.

hasNsProp(self, name, nameSpace)

source code 
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 namespace of None indicates to use the default namespace.

lineNo(self)

source code 
Get line number of @node. This requires activation of this option before invoking the parser by calling xmlLineNumbersDefault(1)

newChild(self, ns, name, content)

source code 
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 node will be created. NOTE: @content is supposed to be a piece of XML CDATA, so it allows entity references. XML special chars must be escaped first by using xmlEncodeEntitiesReentrant(), or xmlNewTextChild() should be used.

newNs(self, href, prefix)

source code 
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.

newTextChild(self, ns, name, content)

source code 
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 string @content. NOTE: Use xmlNewChild() if @content will contain entities that need to be preserved. Use this function, xmlNewTextChild(), if you need to ensure that reserved XML chars that might appear in @content, such as the ampersand, greater-than or less-than signs, are automatically replaced by their XML escaped entity representations.

noNsProp(self, name)

source code 
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 accept only an attribute in no namespace.

nsProp(self, name, nameSpace)

source code 
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 off.

prop(self, name)

source code 
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 associated to the attribute. Use xmlGetNsProp() or xmlGetNoNsProp() for namespace aware processing.

reconciliateNs(self, doc)

source code 
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 as possible the function try to reuse the existing namespaces found in the new environment. If not possible the new namespaces are redeclared on @tree at the top of the given subtree.

replaceNode(self, cur)

source code 
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.

searchNs(self, doc, nameSpace)

source code 
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 declare the namespace within those you will be in troubles !!! A warning is generated to cover this case.

searchNsByHref(self, doc, href)

source code 
Search a Ns aliasing a given URI. Recurse on the parents until it finds the defined namespace or return None otherwise.

setBase(self, uri)

source code 
Set (or reset) the base URI of a node, i.e. the value of the xml:base attribute.

setContent(self, content)

source code 
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().

setContentLen(self, content, len)

source code 
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().

setLang(self, lang)

source code 
Set the language of a node, i.e. the values of the xml:lang attribute.

setNsProp(self, ns, name, value)

source code 
Set (or reset) an attribute carried by a node. The ns structure must be in scope, this is not checked

setProp(self, name, value)

source code 
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.

setSpacePreserve(self, val)

source code 
Set (or reset) the space preserving behaviour of a node, i.e. the value of the xml:space attribute.

unsetProp(self, name)

source code 
Remove an attribute carried by a node. This handles only attributes in no namespace.

isID(self, doc, attr)

source code 
Determine whether an attribute is of type ID. In case we have DTD(s) then this is done if DTD loading has been requested. In the case of HTML documents parsed with the HTML parser, then ID detection is done systematically.

isRef(self, doc, attr)

source code 
Determine whether an attribute is of type Ref. In case we have DTD(s) then this is simple, otherwise we use an heuristic: name Ref (upper or lowercase).