Jump to content

SimpleXml + Media RSS *SOLVED*


ddeile

Recommended Posts

Hello,

I'm new here, love the site.  Anyway, I've been trying to use the SimpleXml module to parse media rss files.  I'm creating a generic rss parser to pull the <media:thumbnail> out of rss feeds.  I've spent the last few days doing this numerous way, but have been unable to return data.

Here are a few of my recent attempts:

[i]Note: I'm using an rss feed from Flickr in these examples.[/i]

[code]
$entries = simplexml_load_file('http://api.flickr.com/services/feeds/photos_public.gne?tags=tokyo&format=rss_200');

foreach($entries->children('http://search.yahoo.com/mrss') as $item)
{
  echo $item->thumbnail->attributes();
}

[/code]

and:

[code]
$entries = simplexml_load_file('http://api.flickr.com/services/feeds/photos_public.gne?tags=tokyo&format=rss_200');
 
foreach($entries->channel->item as $feeditem)
{
$thumbnail = $feeditem->children('http://search.yahoo.com/mrss')->thumbnail->attributes();
}

[/code]

and:

[code]
$entries = simplexml_load_file('http://api.flickr.com/services/feeds/photos_public.gne?tags=tokyo&format=rss_200');
 
foreach($entries->channel->item as $feeditem)
{
foreach ($feeditem->children('http://search.yahoo.com/mrss') as $entry)
        {
            echo $entry->thumbnail->attributes();
        }

}
[/code]

Can anyone offer any help or suggestions?
Link to comment
Share on other sites

SOLVED!

I forgot to echo out my $thumnail variable in my second example.  Here is the code:

[code]$entries = simplexml_load_file('http://api.flickr.com/services/feeds/photos_public.gne?tags=tokyo&format=rss_200');
 
foreach($entries->channel->item as $feeditem)
{
$thumbnail = $feeditem->children('http://search.yahoo.com/mrss')->thumbnail->attributes();
echo $thumbnail[0];
}[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.