I'm new to php 5 and this board so please forgive my being a newbie...
I have a media RSS feed from Brightcove that is formatted as such (I've cut it down for viewing purposes but there are 152 items similar to this one):
Code: Select all
<rss version="2.0" xmlns:bc="http://www.brightcove.com/link" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<item>
<title>2006 Farm Aid</title>
<link>http://link.brightcove.com/services/link/bcpid219243171/bclid232321226/bctid894795069?src=mrss</link>
<description>There are many people who make Farm Aid a success every year, we meet some of them and show clips of Willie Nelson, Neil Young, Dave Matthews, and John Mellencamp performing.</description>
<guid>http://link.brightcove.com/services/link/bcpid219243171/bclid232321226/bctid894795069?src=mrss</guid>
<pubDate>Mon, 14 May 2007 08:01:27 -0700</pubDate>
<media:content medium="video" type="video/x-flv" url="http://brightcove.vo.llnwd.net/d3/unsecured/media/2150793/2150793_893937669_8538c8df441bc0db0b98116d538f154b99a8ecfb.flv"/>
<media:player height="606" url="http://link.brightcove.com/services/link/bcpid219243171/bclid232321226/bctid894795069?src=mrss" width="917"/>
<media:thumbnail url="http://brightcove.vo.llnwd.net/d3/unsecured/media/2150793/2150793_894666376_ad6e1e3dae259a654303498d9c3d52787c5a9e65.jpg"/>
<bc:playerid>219243171</bc:playerid>
<bc:lineupid>232321226</bc:lineupid>
<bc:titleid>894795069</bc:titleid>
</item>
</channel>
</rss>
Code: Select all
$feedUrl = 'http://link.brightcove.com/services/link/bcpid219243171?action=mrss';
$rawFeed = file_get_contents($feedUrl);
$xml = new SimpleXmlElement($rawFeed);
foreach ($xml->channel->item as $item)
{
$title = $item->title;
$link = $item->link;
$description = $item->description;
//
echo "<p><a href=\"$link\">$title</a><br>";
echo "Description: $description";
//
}1. The semicolon in the Brightcove codes:
ex: <bc:titleid>894795069</bc:titleid>
Code: Select all
$feedUrl = 'http://link.brightcove.com/services/link/bcpid219243171?action=mrss';
$rawFeed = file_get_contents($feedUrl);
$xml = new SimpleXmlElement($rawFeed);
foreach ($xml->channel->item as $item)
{
$title = $item->title;
$link = $item->link;
$description = $item->description;
$titleId = $item->bc:titleid;
//
echo "<p>Title ID: $titleId<br>";
echo "<a href=\"$link\">$title</a><br>";
echo "Description: $description";
//
}ex: <media:thumbnail url="http://brightcove.vo.llnwd.net/d3/unsec ... 9e65.jpg"/>
I guess I am wondering 1: how do I escape/get around the colon in my first question, and 2: how do I grab that URL attribute from the media:thumbnail element?
If anyone could point me in the right direction I would really appreciate it. Thanks in advance!
-PM