How to Read an RSS Feed With PHP

<?php
include("../includes/config.php");
include("../includes/dbcon.php");

$tt_res=mysql_query("SELECT *
FROM `rss_data`");

$num = mysql_num_rows($tt_res);
if($num!=0)
{
$tt="TRUNCATE TABLE `rss_data`";
mysql_query($tt);
}



//get the q parameter from URL
$q="yy";

//find out which feed was selected
if($q=="Google")
  {
  $xml=("http://news.google.co.in/news?pz=1&cf=all&ned=in&hl=en&topic=s&output=rss");
  }
elseif($q=="yy")
  {
  $xml=("http://in.news.yahoo.com/rss/cricket");
  }

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

//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;



//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=5; $i++)
  {
  $item_title=$x->item($i)->getElementsByTagName('title')
  ->item(0)->childNodes->item(0)->nodeValue;
  $item_link=$x->item($i)->getElementsByTagName('link')
  ->item(0)->childNodes->item(0)->nodeValue;
  $item_desc=$x->item($i)->getElementsByTagName('description')
  ->item(0)->childNodes->item(0)->nodeValue;
 
  $item_title1=addslashes($item_title);
   $item_desc1=addslashes($item_desc);
 
echo $kk="INSERT INTO `rss_data` (
`item_title` ,
`item_desc`
)
VALUES (
 '".$item_title1."', '".$item_desc1."'
)";

mysql_query($kk);


  }
?>