xml = new XML($parseString); $this->rootTags = array("rss", "rdf:RDF"); $this->itemBranches = array(); $this->parseItemBranches(); } /** * Returns array of references to item branches of the RSS * @method getItemBranches * @returns array of references to objects of type XMLBranch (item branches of RSS) */ function getItemBranches() { return $this->itemBranches; } /** * Returns HTML-formatted RSS items * @method getHTMLTitlesFormatted * @returns string HTML-formatted RSS items */ function getHTMLTitlesFormatted() { $itemBranchesXML = new XML("ul"); reset($this->itemBranches); foreach($this->itemBranches as $newsItem) { $itemXML = new XMLBranch("li"); $itemLinkXML = new XMLBranch("a"); $itemLinkXML->setTagContent($newsItem->getTagContent("item/title")); $itemLinkXML->setTagAttribute("href", $newsItem->getTagContent("item/link")); $itemXML->addXMLBranch($itemLinkXML); $itemBranchesXML->addXMLBranch($itemXML); } return $itemBranchesXML->getXMLString(); } /** * Parses RSS item branches, called from constructor * @method parseItemBranches * @returns true if successful, false otherwise */ function parseItemBranches() { $success = false; $rootTagName = $this->xml->getTagName(); if(in_array($rootTagName, $this->rootTags)) { $tempBranches = array(); if($rootTagName == "rss") $tempBranches = $this->xml->getBranches($rootTagName . "/channel", "item"); elseif($rootTagName == "rdf:RDF") $tempBranches = $this->xml->getBranches($rootTagName, "item"); if($tempBranches !== false) { $this->itemBranches = $tempBranches; $success = true; } } return $success; } } ?>