This function is used for writing rss to a file.
<?php function rss_to_file($url,$file){ $rss = simplexml_load_file($url); if($rss){ $text = ""; $text .= $rss->channel->title."\r\n \r\n \r\n"; $items = $rss->channel->item; foreach($items as $item){ $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; $text .= $title."\r\n"; $text .= $published_on."\r\n"; $text .= $description."\r\n \r\n"; } $handle = fopen($file, 'w'); fwrite($handle, $text); fclose($handle); } return false; } $url = "http://rubensargsyan.wordpress.com/feed/"; // Rss url $file = date("Y-m-d").".txt"; // The file rss_to_file($url,$file); ?> |
If the rss url is wrong the function return false.