ddeile Posted September 24, 2006 Share Posted September 24, 2006 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? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 24, 2006 Share Posted September 24, 2006 try[code]<?php$entries = simplexml_load_file('http://api.flickr.com/services/feeds/photos_public.gne?tags=tokyo&format=rss_200');$data = $entries->xpath ('channel/item/media:thumbnail');foreach ($data as $item) { echo $item['url'].'<br>';} ?>[/code] Quote Link to comment Share on other sites More sharing options...
ddeile Posted September 24, 2006 Author Share Posted September 24, 2006 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] Quote Link to comment Share on other sites More sharing options...
ddeile Posted September 24, 2006 Author Share Posted September 24, 2006 Thanks Barand. That works as well. ;D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.