Getting RSS and XML to work seems to always be a pain, at least that is how it was when I started working with it. All changed when SimpleXML was introduced. Up until I learned about SimpleXML, I always used my own little script that converted a XML feed into a associative array.

With SimpleXML though, it’s a lot simpler to work with feeds.

All you need is the following lines of code:

  $filename = "http://www.phpdeveloping.co.za/feed";
  $feed = simplexml_load_file($filename);
  var_dump($feed);

From here you will see $feed containing all the information you can get from the feed, all neatly structured into an array.

You access the various items through:

$feed->channel->item[n]

As an example:

echo $feed->channel->item[0]->title;
echo $feed->channel->item[0]->link;
echo $feed->channel->item[0]->pubDate;

You can now iterate through all the items doing whatever you want to the data.