6.3.2 Node Objects
- class Node( )
The Node class is the base class for all nodes in the plasTeX DOM inluding elements, text, etc.
- childNodes
a list of the nodes that are contained by this one. In plasTeX, this generally contains the contents of a LaTeX environment.
- nodeName
the name of the node. This is either the special node name as specified in the XML DOM (e.g. #document-fragment, #text, etc.), or, if the node corresponds to an element, it is the name of the element.
- nodeType
integer indicating the type of the node. The node types are defined as:
Node.ELEMENT_NODE
Node.ATTRIBUTE_NODE
Node.TEXT_NODE
Node.CDATA_SECTION_NODE
Node.ENTITY_REFERENCE_NODE
Node.ENTITY_NODE
Node.PROCESSING_INSTRUCTION_NODE
Node.COMMENT_NODE
Node.DOCUMENT_NODE
Node.DOCUMENT_TYPE_NODE
Node.DOCUMENT_FRAGMENT_NODE
Node.NOTATION_NODE
Note: These are defined by the XML DOM, not all of them are used by plasTeX.
- previousSibling
the node in the document that is adjacent to and immediately before this node. If one does not exist, the value is None .
- nextSibling
the node in the document that is adjacent to and immediately after this node. If one does not exist, the value is None .
- str
specifies a string that could be used in place of the node. This string will be converted into tokens in the plasTeX output stream.
- __add__(other )
create a new node that is the sum of self and other . This allows you to use nodes in Python statements like: node + other.
- cloneNode(deep=False )
create a clone of the current node. If deep is true, then the attributes and child nodes are cloned as well. Otherwise, all references to attributes and child nodes will be shared between the nodes.
- __cmp__(other )
same as isEqualNode, but allows you to compare nodes using the Python statement: node == other.
- __getitem__(i )
returns the child node at the index given by i . This allows you to use Python’s slicing syntax to retrieve child nodes: node[i].
- __iadd__(other )
same as extend. This allows you to use nodes in Python statements like: node += other.
- insertBefore(newChild, refChild )
inserts newChild before refChild in this node. If refChild is not found, a NotFoundErr exception is raised.
- __iter__( )
returns an iterator that iterates over the child nodes. This allows you to use Python’s iter() function on nodes.
- __len__( )
returns the number of child nodes. This allows you to use Python’s len() function on nodes.
- pop(index=-1 )
removes child node and the index given by index . If no index is specified, the last child is removed.
- __radd__(other )
create a new node that is the sum of other and self . This allows you to use nodes in Python statements like: other + node.
- replaceChild(newChild, oldChild )
replaces oldChild with newChild in this node. If oldChild is not found, a NotFoundErr exception is raised.
- removeChild(oldChild )
removes oldChild from this node. If oldChild is not found, a NotFoundErr exception is raised.
- __setitem__(i, node )
sets the item at index i to node . This allows you to use Python’s slicing syntax to insert child nodes; see the example below.
mynode[5] = othernode mynode[6:10] = [node1, node2]
- setUserData(key, data )
put data specified in data into the userdata dictionary under the name given by key