Tag Archives: RSS Feed

Script to read RSS feed – PHP

<?php
 $connect = curl_init("http://www.unixsite.com/feed/rss/");
 curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($connect, CURLOPT_HEADER, 0) ;
 $result = curl_exec($connect);
 curl_close($connect);
 $data = new SimpleXmlElement($result, LIBXML_NOCDATA);
 for($i=0;$i<10;++$i) {
  if(empty($data->channel->item[$i]->title)) break;
  echo  $data->channel->item[$i]->title;
  echo  $data->channel->item[$i]->description;
 }
?>