Home | Trees | Index | Help |
---|
Package xmpp :: Module simplexml :: Class Node |
|
DataField
,
DataForm
,
ErrorNode
,
Protocol
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).Method Summary | |
---|---|
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. | |
Deletes node's attribute "item". | |
Reduce memory usage caused by T/NT classes - use memory only when needed. | |
Returns node's attribute "item" value. | |
Sets node's attribute "item" value. | |
Method used to dump node into textual representation. | |
If "node" argument is provided, adds it as child node. | |
Adds some CDATA to node. | |
Removes all CDATA from the node. | |
Deletes an attribute "key" | |
Deletes the "node" from the node's childs list, if "node" is an instance. | |
Returns value of specified attribute. | |
Returns all node's attributes as dictionary. | |
Serialise node, dropping all tags and leaving CDATA intact. | |
Returns all node's child nodes as list. | |
Returns all node CDATA as string (concatenated). | |
Returns the name of node | |
Returns the namespace of node | |
Returns the parent of node (if present). | |
Return the payload of node i.e. | |
Filters all child nodes using specified arguments as filter. | |
Returns attribute value of the child with specified name (or None if no such attribute). | |
Returns cocatenated CDATA of the child with specified name. | |
Filters all child nodes using specified arguments as filter. | |
Checks if node have attribute "key". | |
Sets attribute "key" with the value "val". | |
Sets node's CDATA to provided string. | |
Changes the node name. | |
Changes the node namespace. | |
Sets node's parent to "node". | |
Sets node payload according to the list specified. | |
Same as getTag but if the node with specified namespace/attributes not found, creates such node and returns it. | |
Creates new node (if not already present) with name "tag" and sets it's attribute "attr" to value "val". | |
Creates new node (if not already present) with name "tag" and (optionally) attributes "attrs" and sets it's CDATA to string "val". |
Class Variable Summary | |
---|---|
int |
FORCE_NODE_RECREATION = 0 |
Method Details |
---|
__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. Also the __init__ can be provided with "node"
argument that is either a text string containing exactly one node or
another Node instance to begin with. If both "node" and other
arguments is provided then the node initially created as replica of
"node" provided and then modified to be compliant with other
arguments.
|
__delitem__(self,
item)
Deletes node's attribute "item".
|
__getattr__(self,
attr)
Reduce memory usage caused by T/NT classes - use memory only when
needed.
|
__getitem__(self,
item)
Returns node's attribute "item" value.
|
__setitem__(self,
item,
val)
Sets node's attribute "item" value.
|
__str__(self,
fancy=0)
Method used to dump node into textual representation. if
"fancy" argument is set to True produces indented output for
readability.
|
addChild(self, name=None, attrs={}, payload=[], namespace=None, node=None)If "node" argument is provided, adds it as child node. Else creates new node from the other arguments' values and adds it as well. |
addData(self, data)Adds some CDATA to node. |
clearData(self)Removes all CDATA from the node. |
delAttr(self, key)Deletes an attribute "key" |
delChild(self, node, attrs={})Deletes the "node" from the node's childs list, if "node" is an instance. Else deletes the first node that have specified name and (optionally) attributes. |
getAttr(self, key)Returns value of specified attribute. |
getAttrs(self)Returns all node's attributes as dictionary. |
getCDATA(self)Serialise node, dropping all tags and leaving CDATA intact. That is effectively kills all formatiing, leaving only text were contained in XML. |
getChildren(self)Returns all node's child nodes as list. |
getData(self)Returns all node CDATA as string (concatenated). |
getName(self)Returns the name of node |
getNamespace(self)Returns the namespace of node |
getParent(self)Returns the parent of node (if present). |
getPayload(self)Return the payload of node i.e. list of child nodes and CDATA entries. F.e. for "<node>text1<nodea/><nodeb/> text2</node>" will be returned list: ['text1', <nodea instance>, <nodeb instance>, ' text2']. |
getTag(self, name, attrs={}, namespace=None)Filters all child nodes using specified arguments as filter. Returns the first found or None if not found. |
getTagAttr(self, tag, attr)Returns attribute value of the child with specified name (or None if no such attribute). |
getTagData(self, tag)Returns cocatenated CDATA of the child with specified name. |
getTags(self, name, attrs={}, namespace=None, one=0)Filters all child nodes using specified arguments as filter. Returns the list of nodes found. |
has_attr(self, key)Checks if node have attribute "key". |
setAttr(self, key, val)Sets attribute "key" with the value "val". |
setData(self, data)Sets node's CDATA to provided string. Resets all previous CDATA! |
setName(self, val)Changes the node name. |
setNamespace(self, namespace)Changes the node namespace. |
setParent(self, node)Sets node's parent to "node". WARNING: do not checks if the parent already present and not removes the node from the list of childs of previous parent. |
setPayload(self, payload, add=0)Sets node payload according to the list specified. WARNING: completely replaces all node's previous content. If you wish just to add child or CDATA - use addData or addChild methods. |
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. |
setTagAttr(self, tag, attr, val)Creates new node (if not already present) with name "tag" and sets it's attribute "attr" to value "val". |
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". |
Class Variable Details |
---|
FORCE_NODE_RECREATION
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Oct 5 23:57:40 2006 | http://epydoc.sf.net |