I want to read and save some data from this rss feed to in my database table. The RSS feed is http://feeds.feedburner.com/TechCrunch/.
I have used the following code before to read another RSS feed:
$homepage = file_get_contents('http://rss.cnn.com/rss/edition_technology.rss');
$homepage = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $homepage);
$xml = simplexml_load_string($homepage,'SimpleXMLElement', LIBXML_NOCDATA);
echo '<pre>';
print_r($xml);
foreach($xml->channel->item as $opt) {
$title = mysql_real_escape_string($opt->title);
$link = mysql_real_escape_string($opt->link);
$des = mysql_real_escape_string($opt->description);
// and others
$sql =
"INSERT INTO store_feed (title, link, description)
VALUES('$title','$link','$des')
ON DUPLICATE KEY UPDATE title = '$title', description = '$des'";
$result = mysql_query($sql) or die( mysql_error() );
}
... and I got the desired data, but this time data is different.
I want to store link, description, image, publish date, title of this feed. How can I do this?
I know how to insert into a database but how do I get this data from the RSS feed? Please, I need guidance.