| 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 DocumentFragment node named $booksFrag. $booksFrag->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: $userProfileFrag->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.
|
Returns:
DOMIT_Node - The appended node.
|
Example:
A new node, $brocolli, is appended to $myGroceryListFrag. $myGroceryListFrag->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); |
| Generates an unformatted (single line, no whitespace) string representation of the comment. |
Signature: toString($htmlSafe = false, $subEntities = false) |
Parameters:
boolean htmlSafe - If true, returns an html formatted representation of the string.
boolean subEntities - True if illegal xml characters should be converted to entities.
|
Returns:
String - A string representation of the comment.
|