Sunday, January 2, 2011

How read rss data in php

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

$xml=("http://api.flickr.com/services/feeds/photos_public.gne");

$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

$i=0;
$x=$xmlDoc->getElementsByTagName('entry');
while($i<8)
{
$entry_con=$x->item($i)->getElementsByTagName('content')
->item(0)->childNodes->item(0)->nodeValue;
preg_match_all('/]+>/i',$entry_con, $result); /*to read image from xml feed*/
print $result[0][0];
$i++;
}

No comments:

Post a Comment