| Adds the specified node as a child of the current DOMIT_Element. |
Signature: appendChild(&$child) |
Parameters:
DOMIT_Element child - The node that is to be appended.
|
Returns:
DOMIT_Element - The appended DOMIT_Elementnode.
|
Example:
A child node is appended to the $myElement node: $myElement->appendChild($elementNode); |
| 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); |
| Returns the name of the element tag. |
Signature: getTagName() |
Returns:
String - The name of the element tag.
|
Example:
The tag name is returned. $tagName = $myElement->getTagName(); |
| 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 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(); |
| If a child text node exists, sets the nodeValue to $data. A child text node is created if none exists |
Signature: setText($data) |
Parameters:
string data - The text data of the node.
|
Example:
A child text node is added if none exists and the data added as its nodeValue. $someElement->setText('This is some data'); |
| Returns a NodeList of DOMIT_Elements with the specified nodeName. |
Signature: &getElementsByTagName($tagName) |
Parameters:
String tagName - The nodeName for which to search.
|
Returns:
DOMIT_NodeList - The list of found nodes.
|
Example:
All child Elements named "book" will be returned. $bookCollection =& $libraryElement->getElementsByTagName("book"); |
| Retrieves a NodeList of child elements with the specified namespaceURI and localName. |
Signature: &getElementsByTagNameNS($namespaceURI, $localName) |
Parameters:
String namespaceURI - The matching namespaceURI, or "*" if all elements are to be returned.
String localName - The matching localName, or "*" if all elements are to be returned.
|
Returns:
DOMIT_NodeList - The DOMIT_NodeList of found DOMIT_Elements.
|
Example:
A DOMIT_NodeList of matching elements is returned: $authors =& $library->getElementsByTagNameNS("http://purl.org/dc/elements/1.1", "creator"); |
| 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 value of attribute with the specified name. |
Signature: getAttribute($name) |
Parameters:
String name - The name of the attribute whose value is to be retrieved.
|
Returns:
String - The value of the name attribute, or an empty string if the attribute is not found.
|
Example:
The value of the attribute name "myatt" is returned. $attValue = $anElement->getAttribute("myatt"); |
| Gets the value of the attribute with the specified namespaceURI and localName, if it exists. |
Signature: getAttributeNS($namespaceURI, $localName) |
Parameters:
String namespaceURI - The namespaceURI of the attribute.
String localName - The localName of the attribute.
|
Returns:
String - The value of the attribute, or an empty string if the attribute is not found.
|
Example:
The value of the attribute named "author" in the namespace "http://www.engageinteractive.com" is returned. $attValue = $anElement->getAttributeNS("http://www.engageinteractive.com", "author"); |
| Sets the value of the named attribute. |
Signature: setAttribute($name, $value) |
Parameters:
String name - The name of the attribute whose value is to be set.
String value - The value to which the named attribute should be set.
|
Example:
The value of the attribute named "myatt" is set to "10". $anElement->setAttribute("myatt", "10"); |
| Sets the value of the specified attribute; creates a new attribute if one doesn't exist. |
Signature: setAttributeNS($namespaceURI, $qualifiedName, $value) |
Parameters:
String namespaceURI - The namespaceURI of the attribute whose value is to be set.
String qualifiedName - The qualifiedName of the attribute whose value is to be set.
String value - The value to which the named attribute should be set.
|
Example:
The value of the attribute named "ei:author" is set to "10". $anElement->setAttributeNS("http://www.engageinteractive.com", "ei:author", "10"); |
| Removes the named attribute if it exists. |
Signature: removeAttribute($name) |
Parameters:
String name - The name of the attribute to be removed.
|
Example:
The attribute named "myatt" is removed. $anElement->removeAttribute("myatt"); |
| Removes the specified attribute if it exists. |
Signature: removeAttributeNS($namespaceURI, $localName) |
Parameters:
String namespaceURI - The namespaceURI of the attribute to be removed.
String localName - The localName of the attribute to be removed.
|
Example:
The attribute named "author" in the namespace "http://www.engageinteractive.com" is removed. $anElement->removeAttributeNS("http://www.engageinteractive.com", "author"); |
| Tests whether an attribute with the specified name exists. |
Signature: hasAttribute($name) |
Parameters:
String name - The name of the attribute to test for.
|
Returns:
boolean - True if the attribute exists, false if it does not.
|
Example:
True is returned if the element has an attribute named "myatt". $exists = $anElement->hasAttribute("myatt"); |
| Determines whether an attribute with the specified namespaceURI and localName exists. |
Signature: hasAttributeNS($namespaceURI, $localName) |
Parameters:
String namespaceURI - The namespaceURI of the attribute to test for.
String localName - The localName of the attribute to test for.
|
Returns:
boolean - True if the attribute exists, false if it does not.
|
Example:
True is returned if the element has an attribute named "author" in the namespace "http://www.engageinteractive.com". $exists = $anElement->hasAttributeNS("http://www.engageinteractive.com", "author"); |
| Returns the attribute node with the specified name (not present in DOMIT! Lite). |
Signature: &getAttributeNode($name) |
Parameters:
String name - The name of the attribute to be retrieved.
|
Returns:
DOMIT_Attr - The found attribute, or null if the attribute is not found.
|
Example:
The attribute named "myatt" is returned. $attr =& $anElement->getAttributeNode("myatt"); |
| Gets a reference to the specified attribute node (not present in DOMIT! Lite). |
Signature: &getAttributeNodeNS($namespaceURI, $localName) |
Parameters:
String namespaceURI - The namespaceURI of the attribute to be retrieved.
String localName - The localName of the attribute to be retrieved.
|
Returns:
DOMIT_Attr - The found attribute, or null if the attribute is not found.
|
Example:
The attribute node named "author" in the namespace "http://www.engageinteractive.com" is returned. $attr =& $anElement->getAttributeNodeNS("http://www.engageinteractive.com", "author"); |
| Adds the specified attribute node to the attributes list (not present in DOMIT! Lite). |
Signature: &setAttributeNode(&$newAttr) |
Parameters:
DOMIT_Attr newAttr - The DOMIT_Attr node to be added to the attributes list.
|
Returns:
DOMIT_Attr - The found attribute, or null if the attribute is not found.
|
Example:
The specified attribute node is added to the attributes list. $anElement->setAttributeNode($anAttr); |
| Adds an attribute node to the current element (namespace aware) (not present in DOMIT! Lite). |
Signature: &setAttributeNodeNS(&$newAttr) |
Parameters:
DOMIT_Attr newAttr - The DOMIT_Attr node to be added to the attributes list.
|
Returns:
DOMIT_Attr - The found attribute, or null if the attribute is not found.
|
Example:
The specified attribute node is added to the attributes list. $anElement->setAttributeNodeNS($anAttr); |
| Removes the specified attribute node if it exists (not present in DOMIT! Lite). |
Signature: &removeAttributeNode(&$oldAttr) |
Parameters:
DOMIT_Attr oldAttr - The DOMIT_Attr node to be removed.
|
Returns:
DOMIT_Attr - The found attribute node, or null if the attribute is not found.
|
Example:
The attribute is removed. $anElement->removeAttribute($anAttr); |
| Collapses all adjacent DOMIT_TextNode or DOMIT_CDATASection nodes in the element subtree. |
Signature: normalize() |
Example:
All adjacent text nodes in the subtree of $anElement are collapsed: $anElement->normalize(); |
| Returns an array representation of the element. |
Signature: toArray() |
Returns:
array - An array representing the element.
|
Example:
Prints out an array representing the specified element. print_r($anElement->toArray()); |
| Generates an unformatted (single line, no whitespace) string representation of the element and all children. |
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 in text nodes and attributes should be converted to entities.
|
Returns:
String - An unformatted (single line, no whitespace) string representation of the element and all children.
|
Example:
An unformatted string representation of the element will be printed here: echo ($myElement->toString(true); |