isCollection, getElement, and getElementCount

If a collection of Custom RSS elements is encountered, the isCollection method will return true. To traverse the members of the collection, you can use getElement and getElementCount to set up a for loop through the collection, and then use getElement to grab a reference to each found element.

The found element can then be processed in the same manner as the previous example:


//simple RSS element
if ($parentElement->isSimpleRSSElement($currElementName)) { 
	//process simple element
}
//custom RSS element
else if ($parentElement->isCustomRSSElement($currElementName)) { 
	//process custom element
}
//collection of custom RSS elements
else if ($parentElement->isCollection($currElementName)) { 
	//get a reference to the collection
	$myCollection =& $parentElement->getElement($currElementName);
	
	//get the number of member in the collection
	$numElements = $myCollection->getElementCount(); 

	//loop through the collection
	for ($j = 0; $j < $numElements; $j++) {
		//get a reference to the element
		$myElement =& $myCollection->getElement($j);
		
		//do something with the element using DOM methods
		echo $myNode->toNormalizedString(true);
	}
}


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