I have this php (problem underneath)
<?php
$url = "http://woytest.blogspot.com/feeds/posts/default?alt=rss";
$rss = simplexml_load_file($url);
if($rss){
echo '<h1>'.$rss->channel->title.'</h1>';
$items = $rss->channel->item;
foreach($items as $item){
$title = $item->title;
$link = $item->link;
$img = $item->media:thumbnail->attributes()->url; // error on this line
$description = $item->description;
echo 'Post Title: '.$title.'<br/>';
echo 'Post Link: '.$link.'<br/>';
echo 'Post thumbnail: '.$img.'<br/>';
echo '<br/><br/><br/>';
}
}
?>
the problem is the media:thumbnail with the colon which appears as <media:thumbnail url='...'> on the rss feed how can i overcome the problem i have tried {'media:thumbnail'} replacing just the media:thumbnail in the php but had no luck… I am new to php so could you please explain the error of my ways to.
Take a look at http://alisothegeek.com/2011/07/picking-apart-xml-feeds-and-namespaces-with-php-and-simplexml/
Hopefully this should help you 😉
Example: