Zend_Feed_RSS Categories
Posted: Thu May 13, 2010 4:48 am
I'm reading an RSS feed that contains elements like:
How do I access those categories? I've sort of figured it out using this:
That can't be right though, surely? That's completely abusing the DOM object nodes and accessing things I shouldn't be accessing publicly. I've looked through the documentation for Zend_Feed_Reader but the getCategories() method didn't seem to work for the RSS feed I'm consuming.
Code: Select all
<item>
<title>This is the title</title>
<link>http://link.com/</link>
<description>Description blah blah blah</description>
<category>Gardening</category>
<category>Plants</category>
<category>Flowers</category>
</item>
Code: Select all
$channel = new Zend_Feed_Rss("http://domain.com/rss");
foreach ($channel as $item) {
echo $item->title() . "<br />";
echo $item->description() . "<br />";
$categories = $item->category();
foreach ($categories as $c) {
echo $c->nodeValue;
}
echo "<br /><br />";
}