The Document Object Model specifies a convenience method for obtaining a list of elements
of the same name. The getElementsByTagName method of DOMIT_Document
and DOMIT_Element returns this list as a DOMIT_NodeList.
NOTE: in versions of DOMIT! prior to 0.5, this method returned an array, not a DOMIT_NodeList!
If, for example,. we wished to get a list of our existing cd nodes, we could simply do:
$myCDNodeList =& $cdCollection->getElementsByTagName("cd");
We could then iterate through this array of cd nodes using the DOMIT_NodeList methods
getLength and item:
$total = $myCDNodeList->getLength();
for ($i = 0; $i < $total; $i++) {
$currNode =& $myCDNodeList->item($i);
echo ($currNode->nodeName);
}
|