Inserts node $newChild before $refChild in the childNodes of $this. If $refChild does not exist, $newChild is appended to the node chain. |
Signature: &insertBefore(&$newChild, &$refChild) |
Parameters:
DOMIT_Node newChild - The new node to be added
DOMIT_Node refChild - The existing node before which the new node will be added
|
Returns:
DOMIT_Node - A reference to the new node being added.
|
Example:
The following example inserts a "Book" node named $goodNovel before another named $okNovel in a childNodes list named $bestSellers. $bestSellers->insertBefore($goodNovel, $okNovel); |
Replaces node $oldChild with $newChild. |
Signature: replaceChild(&$newChild, &$oldChild) |
Parameters:
DOMIT_Node newChild - The new node that is to replace the old node.
DOMIT_Node oldChild - The old node that is to be replaced by the new node.
|
Returns:
DOMIT_Node - The new node $newChild, or false if $oldChild does not exist.
|
Example:
An old $userProfile node is replaced by a new node: $userProfile->replaceChild($newProfile, $oldProfile); |
Removes the specified node from the document. |
Signature: &removeChild(&$oldChild) |
Parameters:
DOMIT_Node oldChild - The node that is to be removed.
|
Returns:
DOMIT_Node - The deleted node $oldChild, or false if $oldChild does not exist.
|
Example:
Node $unpopularNovel is removed from the $bestSellers parent node. $bestSellers->removeNode($unpopularNovel); |
Appends the specified node to the childNodes list. |
Signature: appendChild(&$child) |
Parameters:
DOMIT_Node child - The node that is to be appended. If the parent node is of type DOMIT_Document, only a single node can be appended.
|
Returns:
DOMIT_Node - The appended node, or false in the case of DOMIT_TextNode and DOMIT_CDATASection subclasses.
|
Example:
A new node, $brocolli, is appended to the $myGroceryList parent node. $myGroceryList->appendChild($brocolli); |
Determines whether a node has any children. |
Signature: hasChildNodes() |
Returns:
boolean - True if the node has children, false if not.
|
Example:
The following example checks the $cookieJar node to see if it has any children (cookies!). $isCookieJarEmpty = $cookieJar->hasChildNodes(); |
Returns a copy of the specified node, and if $deep is set to true, all nodes below it in the hierarchy. |
Signature: &cloneNode($deep) |
Parameters:
boolean deep - True if the children below the cloned node are also to be cloned.
|
Returns:
DOMIT_Node - The cloned node, with a clone of all subnodes if $deep is set to true.
|
Example:
In the following example, a node named $styleTemplate is cloned, presumably so the user can create a new style based on the characteristics of the original node. $newStyle =& styleTemplate->cloneNode(false); |
Returns a readable representation of the xml document. Note that the class DOMIT_Utilities is required for this function. |
Signature: toNormalizedString() |
Returns:
String - A readable representation of the xml document.
|
Example:
A normalized representation of the xml document is returned: echo (htmlentities("<pre>" . $myDoc->toNormalizedString(). "</pre>")); |