Simple XML in PHP
| From: | Stephen Alistoun | Date: | Tue, 24 Mar 2009 22:02:57 +0000 |
| Subject: | Simple XML in PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-290660@lists.php.net to get a copy of this message | ||
HI all,
How would a get this video from XML.
/***********Example i want to View***********/
<media:content url="http://video-cdn.abcnews.com/090324_gma_leamy.flv"
lang="en" width="424" height="318" type="video/x-flv" />
/**************************************/
/**********************XML CODE***********************/
<title>Investigating Toxic Drywall</title>
<link>http://feedproxy.google.com/~r/AbcNews_Health_Videos/~3/d5ewEbco-js/playerIndex</link>
<description>China-made drywall could be leaching noxious gases into
homes.<img
src="http://feeds2.feedburner.com/~r/AbcNews_Health_Videos/~4/d5ewEbco-js"
height="1" width="1"/></description>
<pubDate>Tue, 24 Mar 2009 10:20:04 -0400</pubDate>
<live:origReleaseDate>Tue, 24 Mar 2009 10:20:04 -0400</live:origReleaseDate>
<media:title>Investigating Toxic Drywall</media:title>
<media:description>China-made drywall could be leaching noxious gases into
homes.</media:description>
<media:keywords>drwall, toxic, china, building, house,
health</media:keywords>
<media:rating>nonadult</media:rating>
<media:thumbnail
url="http://a.abcnews.com/images/GMA/abc_gma_leamy_090324_mn.jpg"
width="320" height="240" />
<media:thumbnail
url="http://a.abcnews.com/images/GMA/abc_gma_leamy_090324_mc.jpg"
width="100" height="75" />
<media:thumbnail
url="http://a.abcnews.com/images/GMA/abc_gma_leamy_090324_mv.jpg"
width="264" height="198" />
<media:content url="http://video-cdn.abcnews.com/090324_gma_leamy.flv"
lang="en" width="424" height="318" type="video/x-flv" />
<media:category>Health</media:category>
/*********************PHP CODE EXAMPLE******************/
$cnt = count($xml->channel->item);
for($i=0; $i<$cnt; $i++)
{
$url = $xml->channel->item[$i]->link;
$title = $xml->channel->item[$i]->title;
$desc = $xml->channel->item[$i]->description;
$pubDate = $xml->channel->item[$i]->pubDate;
echo ' '.$url.' '.$title.' ';
echo "<br />";
echo $desc;
echo "<br />";
echo $pubDate;
echo "<br />";
echo "<br />";
}
--
View this message in context: http://www.nabble.com/Simple-XML-in-PHP-tp22690831p22690831.html
Sent from the PHP - General mailing list archive at Nabble.com.