What is the correct way to go after items more than one level deep with the Zend_Feed library?
How should the second to last line of code read?
require_once 'Zend/Feed/Rss.php';
$url = 'http://leo.am/podcasts/twit';
$c = new Zend_Feed_Rss($url);
$iu = $c->image()->url();
echo $iu;
This was quite interesting!
Your RSS-Feed has two
image
-tags:The first
image
is in the default namespace and has child nodes, this is probably the one you want. The second is apparently iTunes specific and therefore in theitunes
namespace and the url is in thehref
attribute.The Problem is that
$c->image
returns both elements in an array. I'm not sure if it's a bug or if it works as intended.So you have to loop through every element and see if it's from itunes or from rss. This code returns both the itunes and the rss image url in an array as long as they are defined. If none is found the array is empty:
The output looks like this:
Edit: Well there is a concise alternative if you don't care about the iTunes URL:
Output: