The easiest way to go would be to use cURL
to get the info as XML from the rss url, and then use simplexml
to turn the rss XML into a traversable object. Use Xpath to get the parts of the XML you want to store in the DB. Finally, move the data to the DB.
Example
Sorry, I was rushing out the door when I saw your question. I actually wrote a really simple script a week ago to do most of what you are talking about:
//cURL to get RSS as XML
function get_rss($feed_url) {
$feed_request = curl_init($feed_url);
curl_setopt($feed_request, CURLOPT_RETURNTRANSFER, 1);
$feed_xml = curl_exec($feed_request);
curl_close($feed_request);
return $feed_xml;
}
function rss2sql($xml, $sql) {
//simplexml to convert XML to objects
$rss_xml = simplexml_load_string($xml);
//XPath to get an array of items in RSS
$rss_items = $rss_xml -> xpath('//item');
if(!$rss_items) {
die("No Items In RSS Feed!");
}
else {
//Loop through each item, convert to string, insert string to MySQL
foreach($rss_items as $item) {
$item_array = array($item->title,$item->link,$item->guid,$item->description);
$item_sql = "(".implode(","$item_array).")";
$item_sql = $sql -> escape_string($item_sql);
$insert = "INSERT INTO rsstable VALUES('$item_sql');
$sql -> query($insert);
}
}
}
$sql = new mysqli("localhost", "my_user", "my_password", "world");
$rss_url = "http://example.org/rssfeed";
$rss_xml = get_rss($rss_url);
rss2sql($its_rss_alerts_xml, $sql);