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? Link to comment https://forums.phpfreaks.com/topic/21880-simplexml-media-rss-solved/ 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] Link to comment https://forums.phpfreaks.com/topic/21880-simplexml-media-rss-solved/#findComment-97727 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] Link to comment https://forums.phpfreaks.com/topic/21880-simplexml-media-rss-solved/#findComment-97729 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 Link to comment https://forums.phpfreaks.com/topic/21880-simplexml-media-rss-solved/#findComment-97730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.