On Tue, 15 Nov 2011 20:30:29 +0000, Christopher Lee <ct...@ucensys.com> sent:
Hello All,

I am interested in importing RSS Feed content into a MySQL database and displaying the aggregated content on a website. I am thinking of developing the website within a CMS type framework (i.e. Drupal). If anyone can refer me to any resources in this area then that would be great. I hope that I have adequately explained my needs. Thank you all in advance for your help.

First of all, note that not all RSS feeds are the same. Some contain
information and tags that go far beyond the scope of the RSS
standard. Frequently (and hopefully!) these are in different name
spaces. I'll give an example:

If you look at the feed from the USGS on Mag 5+ earthquakes over the
past week at:

  < http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M7.xml >

You will see these sorts of things in each entry:

      <pubDate>Sun, 06 Nov 2011 03:53:10 GMT</pubDate>
      <title>M 5.2, Oklahoma</title>
      <description>November 06, 2011 03:53:10 GMT</description>
      <dc:subject>5.00 km</dc:subject>
      <guid isPermaLink="false">usb0006klz</guid>

The pubDate, title, description, link and guid tags are all part of
the RSS standard. The geo: and dc: tags are not, and are specified in
the opening rss tag:

     <rss version="2.0"

by those xmlns attributes. So, unless you're lucky, almost any canned
solution for dealing with RSS might not work with any particular feed.

The best solution I've come up with just using SimpleXML (or one of
it's derivatives). Here's a quickie I wrote to test out the above

$feed_raw = file_get_contents("http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M2.5.xml";);
        $feed = new SimpleXMLElement($feed_raw);

        echo "<pre>";
        echo "</pre>";

(I know these are going to get wrapped and possibly garbled. See here
for a better view: http://pastebin.com/6k7JPydX)

I really like using SimpleXML -- so far it's met pretty much all my
needs regarding parsing and handling XML data.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to