| 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(); |
| Collapses all adjacent DOMIT_TextNode or DOMIT_CDATASection nodes in the element subtree. |
Signature: normalize() |
Example:
All adjacent text nodes in the subtree of the xml document are collapsed: $xmldoc->normalize(); |
| 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); |
| Applies the specified XPath expression. NOT YET IMPLEMENTED, BUT WILL BE SOON! |
Signature: &selectNodes($pattern) |
Parameters:
String pattern - The XPath expression to be parsed.
|
Returns:
DOMIT_NodeList - An list of DOMIT_Nodes described by the XPath expression.
|
Example:
The first "param" element found with a parent named "params" is returned: $myNodeList =& $someNode->selectNodes("//params/param[1]"); |
| Retrieves an element or DOMIT_NodeList of elements corresponding to the specified "path"-like expression. Relative paths (which do not start with "/"), absolute paths (which start with "/") , and variable paths (which start with "//") are allowed. For more information, please see the DOMIT! Tutorial. For more complex patterns, please see the selectNodes method. |
Signature: &getElementsByPath($pattern, $nodeIndex = 0) |
Parameters:
String pattern - The path-like pattern specifying the elements(s) to be returned.
int nodeIndex - If more than one element matches the specified pattern, setting nodeIndex will return a single node from these possibilities. This is a one-based index.
|
Returns:
Domit_Node - A DOMIT_NodeList of DOMIT_Nodes, or a single DOMIT_Node, described by the expression.
|
Example:
The first "param" element found with a parent named "params" is returned: $myNode =& $xmlDoc->getElementsByPath("//params/param", 1); |
| Returns the text contained in all DOMIT_TextNodes and DOMIT_CDataSections that are children of the specified starting node |
Signature: getText() |
Example:
All text and cdata nodes in the document will be concatenated and returned. $allDocmentText = $xmldoc->getText(); |
| Indicates whether the specified feature is supported by the DOM implementation and this node. |
Signature: isSupported($feature, $version = null) |
Parameters:
String feature - The feature.
String version - The version of the DOM implementation.
|
Example:
Queries whether HTML DOM is supported. echo $myDoc->isSupported('HTML', '2.0'); |
| A function called immediately after the DOM document has been generated. Useful for initializing nodes derived from the standard DOMIT nodes. This method must be overridden! See loadXML and saveXML for more information on how to invoke this method. |
Signature: onLoad() |
| Outputs <pre> formatted text that has had htmlEntities() applied. |
Signature: forHTML($text, $doPrint = false) |
Parameters:
String text - The text to be output.
String doPrint - True if output should be dumped to the browser, false if it should just be returned. Default is false.
|
Returns:
String - The resulting formatted text.
|
| Returns an array representation of the xml document. |
Signature: toArray() |
Returns:
array - An array representing the xml document.
|
| Returns a readable representation of the xml document. Note that the class DOMIT_Utilities is required for this function. |
Signature: toNormalizedString($htmlSafe = false, $subEntities=false) |
Parameters:
boolean htmlSafe - If true, returns an html formatted representation of the string.
boolean subEntities - True if illegal xml characters in text nodes and attributes should be converted to entities.
|
Returns:
String - A readable representation of the xml document.
|
Example:
A normalized representation of the xml document is returned, formatted for display in a browser: echo $myDoc->toNormalizedString(true); |