[All Packages]  [This Package]  [Previous Class]  [Next Class]

Class: Node

This class contains methods for details about a document node


Method Index

appendChild Append a new child to the end of the current node's list of children
cloneNode Clone an existing node and optionally all its children
getAttributes Return structure contains all defined node attributes
getChildNode Return specific indexed child of given node
getChildNodes Return structure contains all child nodes of given node
getContext Get node's context
getFirstChild Return first child of given node
getLastChild Return last child of given node
getLocal Returns the local name of the node
getNamespace Return a node's namespace
getNextSibling Return a node's next sibling
getName Return name of node
getType Return numeric type-code of node
getValue Return "value" (data) of node
getOwnerDocument Return document node which contains a node
getParentNode Return parent node of given node
getPrefix Returns the namespace prefix for the node
getPreviousSibling Returns the previous sibling of the current node
getQualifiedName Return namespace qualified node of given node
hasAttributes Determine if node has any defined attributes
hasChildNodes Determine if node has children
insertBefore Insert new child node into a node's list of children
numChildNodes Return count of number of child nodes of given node
print Format XML document to stream or buffer
printSize Determine size of formatted XML document (without outputting)
removeChild Remove a node from the current node's list of children
replaceChild Replace a child node with another
setValue Sets a node's value (data)

Methods

appendChild

Function:
Append a new child to the current node's list of children

Prototype:
Node* appendChild(Node *newChild)

Arguments:
newChild -- new child node

Returns:
Node* -- newChild is passed back

cloneNode

Function:
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (parentNode returns NULL).

Cloning an Element copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child Text node. Cloning any other type of node simply returns a copy of this node.

Prototype:
Node* cloneNode(boolean deep)

Arguments:
deep -- recursion flag

Returns:
Node* -- Pointer to new clone

getAttributes

Function:
Return structure of all attributes for node

Prototype:
NamedNodeMap* getAttributes()

Arguments:
None

Returns:
NamedNodeMap* -- Pointer to structure describing all attributes for node, or NULL if no attributes are defined

getChildNode

Function:
Return one of the node's children

Prototype:
Node* getChildNode(uword index)

Arguments:
index -- child number, starting at 0

Returns:
Node* -- Pointer to index'th child of node

getChildNodes

Function:
Return node's children

Prototype:
NodeList* getChildNodes()

Arguments:
None

Returns:
NodeList* -- Pointer to structure describing all the node's children

getContext

Function:
Return node's context

Prototype:
xmlctx* getContext()

Arguments:
None

Returns:
xmlctx* -- Node's context

getFirstChild

Function:
Return the node's first child

Prototype:
Node* getFirstChild()

Arguments:
None

Returns:
Node* -- Pointer to the node's first child

getLastChild

Function:
Return the node's last child

Prototype:
Node* getLastChild()

Arguments:
None

Returns:
Node* -- Pointer to the node's last child

getLocal

Function:
Return the node's local name

Prototype:
DOMString getLocal()

Arguments:
None

Returns:
DOMString -- node's local name

getNamespace

Function:
Return the node's namespace

Prototype:
DOMString getNamespace()

Arguments:
None

Returns:
DOMString -- node's namespace (may be NULL)

getNextSibling

Function:
Returns the next sibling of the node, that is, the child of its parent which comes next

Prototype:
Node* getNextSibling()

Arguments:
None

Returns:
Node* -- Node's next sibling, NULL if last child

getName

Function:
Return name of node, or NULL if the node has no name

Prototype:
DOMString getName()

Arguments:
None

Returns:
DOMString -- Node's name

getType

Function:
Return numeric type-code for node

Prototype:
short getType()

Arguments:
None

Returns:
short -- Node's numeric type code

Type codes:
ELEMENT_NODE
ATTRIBUTE_NODE
TEXT_NODE
CDATA_SECTION_NODE
ENTITY_REFERENCE_NODE
ENTITY_NODE
PROCESSING_INSTRUCTION_NODE
COMMENT_NODE
DOCUMENT_NODE
DOCUMENT_TYPE_NODE
DOCUMENT_FRAGMENT_NODE
NOTATION_NODE

getValue

Function:
Return "value" (data) of node, or NULL if the node has no value

Prototype:
DOMString getValue()

Arguments:
None

Returns:
DOMString -- Node's "value"

getOwnerDocument

Function:
Return document node which contains the current node

Prototype:
Document* getOwnerDocument()

Arguments:
None

Returns:
Document* -- Pointer to document node

getParentNode

Function:
Return node's parent

Prototype:
Node* getParentNode()

Arguments:
None

Returns:
Node* -- Pointer to the node's parent node


getPrefix

Function:
Return the namespace prefix of node

Prototype:
DOMString getPrefix()

Arguments:
None

Returns:
DOMString -- Node's namespace prefix, may be NULL

getPreviousSibling

Function:
Returns the previous sibling of the node, that is, the child of its parent which came before

Prototype:
Node* getPreviousSibling()

Arguments:
None

Returns:
Node* -- Node's previous sibling, NULL if first child

getQualifiedName

Function:
Return the fully qualified (namespace) name of node

Prototype:
DOMString getQualifiedName()

Arguments:
None

Returns:
DOMString -- Node's qualified name

hasAttributes

Function:
Determine if node has any defined attributes

Prototype:
boolean hasAttributes()

Arguments:
None

Returns:
boolean -- TRUE if node has attributes

hasChildNodes

Function:
Determine if node has any children

Prototype:
boolean hasChildNodes()

Arguments:
None

Returns:
boolean -- TRUE if node has child nodes

insertBefore

Function:
Insert a new child node into the list of children of a parent, before the reference node. If refChild is NULL, appends the new node to the end.

Prototype:
Node* insertBefore(Node *newChild, Node *refChild)

Arguments:
newChild -- new node to insert
refChild -- reference node; new node comes before

Returns:
Node* -- newChild passed back

numChildNodes

Function:
Return count of node's children

Prototype:
uword numChildNodes()

Arguments:
None

Returns:
uword -- Number of children this node has (might be 0)

print

Function:
Format XML document to stream or buffer

Prototype:
void print(FILE *out = stdout, uword level = 0, uword step = 4)
void print(DOMString buffer, size_t bufsize, uword level = 0, uword step = 4)

Arguments:
out -- stdio output stream
buffer -- destination buffer
bufsize -- size of destination buffer
level -- starting indentation level
step -- spaces per indentation level

Returns:
void

printSize

Function:
Return size (in bytes) of formatted XML document, without actually outputting it. Useful for determining final size of document for buffer allocation purposes. Caution, this call is almost as expensive as really outputting the document!

Prototype:
size_t printSize(uword level = 0, uword step = 4)

Arguments:
level -- starting indentation level
step -- spaces per indentation level

Returns:
size_t -- size of formatted document, in bytes

removeChild

Function:
Remove a node from its parents' list of children

Prototype:
Node* removeChild()

Arguments:
None

Returns:
Node* -- removed node is passed back

replaceChild

Function:
Replace current node with another.

Prototype:
Node* replaceChild(Node *newChild)

Arguments:
newChild -- new replacement node

Returns:
Node* -- original node is returned

setValue

Function:
Sets a node's "value" (data)

Prototype:
void setValue(DOMString data)

Arguments:
data -- New data for node

Returns:
void