Class DOMIT_ChildNodes_Interface
A class abstracting the functionality for manipulating childNodes.

isPublic? yes
isAbstract? yes

Inheritance tree:


DOMIT_Node
|
DOMIT_ChildNodes_Interface

Known subclasses:

DOMIT_Document, DOMIT_DocumentFragment, DOMIT_Element

Source file: xml_domit_parser.php




Constructor



Public Constants



Private Constants



Public Fields



Private Fields



Public Methods
appendChild
Adds the specified node as a child of the current node.

Signature: &appendChild(&$child)

Parameters:

DOMIT_Node child - The node that is to be appended.

Returns:

DOMIT_Node - The appended node.

Example:

A child node is appended to the $myElement node:

$myElement->appendChild($elementNode);

insertBefore
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);

replaceChild
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);

removeChild
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);

getElementsByAttribute
Searches the element tree for an element with the specified attribute name and value (intended as a namespace unaware substitute for getElementByID).

Signature: &getElementsByAttribute($attrName = 'id', $attrValue = '', $returnFirstFoundNode = false)

Parameters:

String attrName - The value of the attribute.

String attrValue - The name of the attribute.

boolean returnFirstFoundNode - True if the first found node is to be returned as a node instead of a nodelist.

Returns:

DOMIT_NodeList - A NodeList of found elements, or null.

Example:

A node list of elements with an attribute named 'myAttr' and a value of '3' is returned.

$myNodeList =& $xmldoc->getElementsByAttribute('myAttr', '3');




Private Methods
_getElementsByAttribute
Searches the element tree for an element with the specified attribute name and value.

Signature: _getElementsByAttribute(&$nodelist, $attrName, $attrValue, $returnFirstFoundNode, $foundNode = false)

Parameters:

DOMIT_NodeList nodelist - The node list of found elements.

String attrName - The value of the attribute.

String attrValue - The name of the attribute.

boolean returnFirstFoundNode - True if the first found node is to be returned as a node instead of a nodelist.

boolean foundNode - True the node has been found.

Returns:

DOMIT_NodeList - A NodeList of found elements, or null.


Documentation generated by ClassyDoc, using the DOMIT! and SAXY parsers.
Please visit Engage Interactive to download free copies.