XML_Feed_Parser
Language: PHP
Date: June 2005-present
Following the lead set by Mark Pilgrim's Universal Feed Parser, which makes working with feeds in python a breeze, I have shaped some classes that I hope will provide a similar level of flexibility and abstraction for PHP coders.
My code was accepted for inclusion in PEAR on Monday October 10th 2005, reached a beta release in January '06 and was released in a stable form on Boxing Day 2006. It is now available from its package page. You can get it through the PEAR installer with:
% pear install XML_Feed_Parser
The latest development can be found in PEAR CVS.
At present the package provides support for Atom 1.0, RSS 0.90, 0.91, 0.92, 1.0 and 2.0. Atom 1.0 is considered normative, and fallbacks are provided in the RSS classes to allow developers to focus on the atom standard while working with all three formats.
There are lots of regression tests in place and some basic support for parsing and using the test suite that comes with the Universal Feed Parser.
Example
Full documentation is in the PEAR manual, but for now here's a very simple example of using the parser:
<?php
require_once "XML/Feed/Parser.php";
$feed_xml = file_get_contents("my_feed.xml");
try {
$parser = new XML_Feed_Parser($feed_xml);
} catch (XML_Feed_Parser_Exception $e) {
die("Feed Parsing Failed");
}
print "<h1>" . $parser->title . " Entries</h1>";
print "<ul>";
foreach ($parser as $entry) {
print "<li>" . $entry->title . "</li>\n";
}
print "</ul>";
?>
