Class DOMIT_NamedNodeMap
Provides a container for an unordered list of nodes that can be accessed by their nodeNames.

isPublic? yes
isAbstract? no

Inheritance tree:

DOMIT_NamedNodeMap (top level class)

Known subclasses:

DOMIT_NamedNodeMap_Attr

Source file: xml_domit_nodemaps.php




Constructor



Public Constants



Private Constants



Public Fields



Private Fields
arNodeMap
An associative array containing the list of DOMIT_Nodes.

Type: array

indexedNodeMap
A numerical index to the keys of the mapped nodes.

Type: array

isDirty
True if the list has been modified and $indexedNodeMap needs reindexing.

Type: boolean




Public Methods
item
Returns the node at the specified index (0-based).

Signature: &item($index)

Parameters:

int index - The index of the DOMIT_Node to be returned.

Returns:

DOMIT_Node - The DOMIT_Node at the index specified, or null if nothing is found at that location.

Example:

The third node in the node list is returned:

$thirdNode =& myNodeList->item(2);

getLength
Returns the number of nodes in the node map.

Signature: getLength()

Returns:

int - The number of nodes in the node map.

Example:

The number of nodes in the node map are returned:

$numNodes = myNodeMap->getLength();

reindexNodeMap
Reindexes the numerical index for the named node map.

Signature: reindexNodeMap()

getNamedItem
Gets the node with the specified nodeName from the list, or returns null.

Signature: &getNamedItem($name)

Parameters:

String node - The name of the node to be retrieved.

Returns:

DOMIT_Node - The node to be returned.

Example:

A node named "param" is returned from $myNodeMap:

$returnedNode =& myNodeMap->getNamedItem("param");

getNamedItemNS
Gets a node with the specifed name, taking into account namespaces.

Signature: &getNamedItemNS($namespaceURI, $localName)

Parameters:

String namespaceURI - The namespaceURI of the node to be retrieved.

String localName - The localName of the node to be retrieved.

Returns:

DOMIT_Node - The node to be returned.

Example:

A node named "param" in namespace "http://www.engageinteractive.com" is returned from $myNodeMap:

$returnedNode =& myNodeMap->getNamedItemNS("http://www.engageinteractive.com", "param");

setNamedItem
Adds the specified node to the node map, using its nodeName as key. Overwrites an existing named item.

Signature: &setNamedItem(&$arg)

Parameters:

DOMIT_Node arg - The node to be added.

Returns:

DOMIT_Node - Null, or the node that was overwritten if this is the case.

Example:

A node is added to $myNodeMap:

myNodeMap->setNamedItem($aNode);

setNamedItemNS
Adds the specified node to the node map, using its using its namespaceURI and localName as key. Overwrites an existing named item.

Signature: &setNamedItemNS(&$arg)

Parameters:

DOMIT_Node arg - The node to be added.

Returns:

DOMIT_Node - Null, or the node that was overwritten if this is the case.

Example:

A node is added to $myNodeMap:

myNodeMap->setNamedItemNS($aNode);

removeNamedItem
Removes the node with the specified nodeName from the node map.

Signature: &removeNamedItem($name)

Parameters:

String name - The nodeName of the node to be removed.

Returns:

DOMIT_Node - The node that was just removed, or null if it wasn't found.

Example:

A node named "param" is removed from $myNodeMap:

$returnedNode =& myNodeMap->removeNamedItem("param");

removeNamedItemNS
Removes a node from the list, by name, by local name and namespace URI.

Signature: &removeNamedItemNS($namespaceURI, $localName)

Parameters:

String namespaceURI - The namespaceURI of the node to be removed.

String localName - The localName of the node to be removed.

Returns:

DOMIT_Node - The node that was just removed, or null if it wasn't found.

Example:

A node named "param" in namespace "http://www.engageinteractive.com" is removed from $myNodeMap:

$returnedNode =& myNodeMap->removeNamedItemNS("http://www.engageinteractive.com", "param");

toArray
Returns an array representation of the named node map.

Signature: toArray()

Returns:

array - An array representing the named node map.

Example:

Prints out an array representing the named node map.

print_r($nodemap->toArray());

forHTML
Formats a string for presentation as HTML.

Signature: forHTML($str, $doPrint = false)

Parameters:

String str - The string to be formatted.

boolean doPrint - True if the string is to be sent directly to output.

Returns:

String - The HTML formatted string.

toString
Generates an unformatted (single line, no whitespace) string representation of the NamedNodeMap.

Signature: toString($htmlSafe = false, $subEntities=false)

Parameters:

boolean htmlSafe - True if HTML readable output is desired.

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 NamedNodeMap.

Example:

An unformatted string representation of the NamedNodeMap will be printed here:

echo $myNodeMap->toString(true, true);




Private Methods
getKeyNS
Returns the key of the NamedNodeMap, given the namespaceURI and localName.

Signature: getKeyNS($namespaceURI, $localName)

Parameters:

String namespaceURI - The namespaceURI of the node to be removed.

String localName - The localName of the node to be removed.

Returns:

String - The key of the NamedNodeMap.

createClone
Used by cloneNode() to generate a new instance of a DOMIT_NamedNodeMap containing the same data as the original.

Signature: &createClone($deep)

Parameters:

boolean deep - True if all subnodes are to be cloned.

Returns:

DOMIT_NamedNodeMap - A new DOMIT_NamedNodeMap


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