Testing for RSS Element Type: isSimpleRSSElement, isCustomRSSElement, and isCollection

Given the stratification of RSS elements into simple, complex, custom, and collection types, it is easy using DOMIT! RSS to:

  • get a list of available elements

  • iterate through the elements in the list

  • test each element to determine its type

  • query each element for data, based on the type of that element

First an elementList loop is set up using the getElementList and getElementCount methods:


$elementList =& $channelElement->getElementList();
$numElements = count($elementList);

for ($i = 0; $i < $numElements; $i++) {
	$currElementName =& $elementList[$i];
	
	//process found elements
}

The methods isSimpleRSSElement, isCustomRSSElement, and isCollection can then be used to determine the type of each element:

						
$elementList =& $parentElement->getElementList();
$numElements = count($elementList);

for ($i = 0; $i < $numElements; $i++) {
	$currElementName =& $elementList[$i];
	
	//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)) { 
		//process collection
	}
	//complex RSS element
	else { 
		//process complex element
	}
}


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