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:


= new rss_php;


    $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.

Full documentation and examples of RSS_PHP are available on the site, or you can download the latest version of RSS_PHP for all your RSS & XML Parsing needs.

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 ;).

Additional functionality of RSS_PHP Commercial (v3):

  • Full XML Parser, parse anything XML Based
  • Array to XML conversion, convert XML to Arrays and Arrays to XML [array to xml example]
  • XML Modification, turn XML into an array, change values and write the XML back out, preserving the original formatting
  • Automatic XML Encoding Detection and conversion to UTF-8
  • XPath support and functionality
  • Greater flexibility with the addition of getElementsByTagName and getValuesByTagName
  • Preliminary ATOM feed support
  • Support of XML Namespaces and DOM Processing Instructions (XML Style-sheets)
  • Custom Integrated HTTP Transport Handler

Our original version (RSS_PHP v1) is still freely available.

Download page for Commercial & Free Version

IMPORTANT: getChannel() function deprication.

In version 3 of RSS_PHP the RSS Parser specific function getChannel() has been depricated; users are encouraged to use any of query('xpath/here'), getElementsByTagName('tagname') or getValuesByTagName('tagname') instead.

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:

RSS_PHP supports all flavours of RSS 2.0; including all its wacky permutations, some of these include:

Valid XHTML 1.0 Strict

return to the top of the page