The final type of element that can be queried using DOMIT! RSS -- Complex RSS Elements -- is comprised of various types of predefined RSS elements, each with its own methods.
A switch statement, trapping for the equivalent DOMIT! RSS element constant, is the best means of filtering one element from the other.
There are two caveats to this approach:
The first is that the DOMIT! RSS element constants are all lower case strings, so you should convert the element name in the switch statement to lower case as well.
The second caveat is that before executing the switch statement, you should use !is_array($element) to exclude any of the specially indexed DOMIT! RSS collections (i.e., domit_rss_channels, domit_rss_items, and domit_rss_categories).
//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 {
//get reference to element
$element =& $parentElement->getElement($currElement);
if (!is_array($element)) { //exclude domit_rss_channels,
//domit_rss_items,
//and domit_rss_categories arrays
switch (strtolower($currElement)) {
case DOMIT_RSS_ELEMENT_IMAGE:
//process image element
break;
case DOMIT_RSS_ELEMENT_CLOUD:
//process cloud element
break;
case DOMIT_RSS_ELEMENT_TEXTINPUT:
//process textinput element
break;
case DOMIT_RSS_ELEMENT_ENCLOSURE:
//process enclosure element
break;
case DOMIT_RSS_ELEMENT_SOURCE:
//process source element
break;
case DOMIT_RSS_ELEMENT_GUID:
//process guid element
break;
}
}
}
|