Node class describes syntax of separate XML Node. It have a
constructor that permits node creation from set of "namespace
name", attributes and payload of text strings and other nodes. It
does not natively support building node from text string and uses
NodeBuilder class for that purpose. After creation node can be mangled in
many ways so it can be completely changed. Also node can be serialised
into string in one of two modes: default (where the textual
representation of node describes it exactly) and "fancy" - with
whitespace added to make indentation and thus make result more readable
by human.
Node class have attribute FORCE_NODE_RECREATION that is defaults to
False thus enabling fast node replication from the some other node. The
drawback of the fast way is that new node shares some info with the
"original" node that is changing the one node may influence the
other. Though it is rarely needed (in xmpppy it is never needed at all
since I'm usually never using original node after replication (and using
replication only to move upwards on the classes tree).
|
__init__(self,
tag=None,
attrs={ } ,
payload=[ ] ,
parent=None,
node=None)
Takes "tag" argument as the name of node (prepended by
namespace, if needed and separated from it by a space), attrs
dictionary as the set of arguments, payload list as the set of
textual strings and child nodes that this node carries within itself
and "parent" argument that is another node that this one
will be the child of. |
source code
|
|
|
|
|
|
|
addChild(self,
name=None,
attrs={ } ,
payload=[ ] ,
namespace=None,
node=None)
If "node" argument is provided, adds it as child
node. |
source code
|
|
|
addData(self,
data)
Adds some CDATA to node. |
source code
|
|
|
clearData(self)
Removes all CDATA from the node. |
source code
|
|
|
delAttr(self,
key)
Deletes an attribute "key" |
source code
|
|
|
delChild(self,
node,
attrs={ } )
Deletes the "node" from the node's childs list, if
"node" is an instance. |
source code
|
|
|
getAttrs(self)
Returns all node's attributes as dictionary. |
source code
|
|
|
getAttr(self,
key)
Returns value of specified attribute. |
source code
|
|
|
getChildren(self)
Returns all node's child nodes as list. |
source code
|
|
|
getData(self)
Returns all node CDATA as string (concatenated). |
source code
|
|
|
|
|
getNamespace(self)
Returns the namespace of node |
source code
|
|
|
getParent(self)
Returns the parent of node (if present). |
source code
|
|
|
|
|
getTag(self,
name,
attrs={ } ,
namespace=None)
Filters all child nodes using specified arguments as filter. |
source code
|
|
|
getTagAttr(self,
tag,
attr)
Returns attribute value of the child with specified name (or None
if no such attribute). |
source code
|
|
|
getTagData(self,
tag)
Returns cocatenated CDATA of the child with specified name. |
source code
|
|
|
getTags(self,
name,
attrs={ } ,
namespace=None,
one=0)
Filters all child nodes using specified arguments as filter. |
source code
|
|
|
setAttr(self,
key,
val)
Sets attribute "key" with the value "val". |
source code
|
|
|
|
|
|
|
setNamespace(self,
namespace)
Changes the node namespace. |
source code
|
|
|
|
|
|
|
setTag(self,
name,
attrs={ } ,
namespace=None)
Same as getTag but if the node with specified namespace/attributes
not found, creates such node and returns it. |
source code
|
|
|
setTagAttr(self,
tag,
attr,
val)
Creates new node (if not already present) with name
"tag" and sets it's attribute "attr" to value
"val". |
source code
|
|
|
setTagData(self,
tag,
val,
attrs={ } )
Creates new node (if not already present) with name
"tag" and (optionally) attributes "attrs" and
sets it's CDATA to string "val". |
source code
|
|
|
has_attr(self,
key)
Checks if node have attribute "key". |
source code
|
|
|
__getitem__(self,
item)
Returns node's attribute "item" value. |
source code
|
|
|
__setitem__(self,
item,
val)
Sets node's attribute "item" value. |
source code
|
|
|
__delitem__(self,
item)
Deletes node's attribute "item". |
source code
|
|
|
__getattr__(self,
attr)
Reduce memory usage caused by T/NT classes - use memory only when
needed. |
source code
|
|