Just wondering if someone could suggest a PHP library that would allow me to read the data of an RSS feed and write it to a MySQL database. Also, if possible, provide a link
Reading data that simple is something you could use simplexml for.
http://www.ibm.com/developerworks/library/x-simplexml.html
From there you can see how easy it is to grab the data, instead of displaying, you store in a database.
Gotchas: badly formatted rss (see above tut) different flavours of rss (ditto) evil values in the rss - it's foreign data and should be handled with suspicion dependency on allow_url_fopen - maybe use cURL
Simplepie is probably the most popular PHP RSS library.
RSS is a pretty simple format - there is no great need to use a separate library.
I'd just use simplexml, because I don't wanna spend the effort learning another library, and keeping up with its development.
Here is a simple PHP script for showing the latest Stackoverflor posts with simplexml:
<?php
$rss = simplexml_load_file('http://stackoverflow.com/feeds');
?>
<h1><?php echo $rss->title; ?></h1>
<ul>
<?php
foreach($rss->entry as $e) {
echo "<li><a href=\"".$e->link['href']."\">";
echo $e->title;
echo "</a></li>\n";
}
?>
</ul>
SimplePie is definitely the way to go. You can download and parse an RSS feed in under 10 lines of code. There is a tutorial here that shows you how.
Magpie is an excellent RSS library
http://magpierss.sourceforge.net/
There's an example of using it here: http://www.olate.co.uk/articles/view.php?id=214
Once you've used Magpie to grab an RSS feed you can store it in a string a save to a DB as you would with any other string.
You can also give XPath a try, pretty simple to use.