RSS_PHP;
a free RSS Parser & XML Parser for PHP 5+

The RSS_PHP commercial version (v3) is now more of an XML_PHP - you can use it to quickly interface with ANY XML document; Further, you can now also convert any Array to XML.

RSS_PHP Introduction

RSS_PHP is a RSS Parser and XML Parser for PHP 5+, utilising the DOM to parse any valid XML Document including RSS, with provisional support for ATOM feeds.

Unlike many RSS Parsers, RSS_PHP also gives you full access to every part of the original RSS feed; including RSS attributes, RSS extensions, XML namespaces, XML stylesheets and node values.

This RSS Parser was created to be as simple as possible. Here's a working example which will parse a full RSS feed, it'll also automatically convert the XML Document to UTF-8 from any other encoding:

<?php

$rss = new rss_php;

$rss->load('http://rssphp.net/rss.xml');

$items = $rss->getItems(); #returns all rss items

?>

IMPORTANT: A major peice of relatively unknown functionality is that RSS_PHP returns the actual DOMElements from the raw DOMDocument (although they have been modified slightly) - meaning that from any returned element you can access the full DOMDocument and have access to all the normal PHP DOM properties and methods.

Commercial version (v3) released

A commercial version (v3) of the RSS Parser / XML Parser for PHP [rss_php] is now released and available for download. This release fixes a couple of tiny bugs and adds far more functionality (its now more of an XML-PHP ;).

RSS_PHP Information

I've spent years using XML in all it's formats, within that time I've seen literally thousands of people ask how can I parse RSS with PHP?; and the majority of the time the answer has been quite simply: use REGEX.

Personally, I think REGEX is fine solution, I've even used it to built my own XML & Markup parsers and established PHP frameworks on them, however the aim should be to keep things Really Simple, seeing as RSS isn't exactly the most complicated XML document to date.

Thankfully PHP (5+) already gives us everything we need to get started parsing RSS and XML, indeed it negates the need for REGEX or third-party extensions such as expat in this context.

Parsing RSS and XML in PHP using DOM Functions

With PHP 5 came the intoduction of the DOM Extension; to quote directly from the source:

The DOM extension allows you to operate on XML documents through the DOM API with PHP 5.

Rather than using any third party modules, or custom XML parsers like many other RSS parsers; RSS_PHP makes good use of the aforementioned DOM Extension.

RSS_PHP Dependencies

As RSS_PHP utilises the DOM to parse RSS, and the DOM Extension is installed as part of the PHP Core, RSS_PHP's only dependency is PHP 5.

RSS_PHP Internationalization and Character Encoding Support

RSS_PHP now features automatic XML Encoding Detection and conversion to UTF-8

Supported Versions of RSS

RSS_PHP works with all versions of RSS, including related modules, attributes and extensions, currently tested and verified against: