MagpieRSS
MagpieRSS provides an XML-based (expat) RSS parser in PHP. MagpieRSS is compatible with RSS 0.9 through RSS 1.0. MagpieRSS can also parse RSS 1.0’s modules, RSS 2.0, and Atom. (with a few exceptions). In other words, it is the Swiss army knife of RSS parsers.
WordPress have already integrated the MagpieRSS PHP class into its code, so it’s super easy to use MagpieRSS in WordPress.
<?php include_once(ABSPATH . WPINC . ‘/rss.php‘); $rss = fetch_rss(‘http://feed.fairyfish.net/‘); $maxitems = 5 $items = array_slice($rss->items, 0, $maxitems) ?>
The code above will fetch the first 5 items of the feed ( http://feed.fairyfish.net/), and then store it in an array items. To see the detail of the array just use the PHP function print_r to print it.
You can use another function wp_rss in WordPress to retrieves an RSS feed and then parses it. It will then display it as an unordered list of links.
<?php include_once(ABSPATH . WPINC . ‘/rss-functions.php‘) wp_rss(‘http://feed.fairyfish.net/‘, 5) ?>
The function have two parameters, the first one is the feed you want to parse and the second one is used to set how many items you want to output.