RSS-PHP RSS Parser Examples

The examples below are for RSS-PHP version 1 - new examples will be added for the new more powerful RSS-PHP version 3 in the next couple of days.

These examples are listed here purely to show the capabilities of RSS-PHP, they are to be used for reference only; rssphp.net does not promote the use of these scripts in a production environment.

SourceForge.net Logo

Digg Front Page RSS to XHTML using RSS_PHP

This simple little script will use the RSS-PHP RSS Parser to retrieve digg's front page RSS and display as XHTML.

<?php
require_once 'rss_php.php';    

    $rss = new rss_php;
    $rss->load('http://digg.com/rss/index.xml');
    $items $rss->getItems();

    $html '';
    foreach($items as $index => $item) {
        $html .= '<p><a href="'.$item['link'].'" title="'.$item['title'].'"><strong>'.$item['title'].'</strong></a><br />
                    '
.$item['description'].'<br />
                    Submitted by: <a href="'
.$item['digg:submitter']['digg:userimage'].'">'.$item['digg:submitter']['digg:username'].'</a> :: '.$item['pubDate'].'<br />
                    Diggs: '
.$item['digg:diggCount'].' :: <em>Category: '.$item['digg:category'].'</em>
                    </p>'
;
    }
    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Digg Front Page</title>
</head>

<body>
<?php
echo $html;
?>
</body>
</html>

Google News RSS to JSON for use with AJAX

Here's a simple RSS-PHP solution to convert Google News RSS to JSON using RSS-PHP:

<?php
require_once 'rss_php.php';    

    $rss = new rss_php;

    $rss->load('http://news.google.com/?output=rss');
    
    echo json_encode($rss->getRSS());
    
?> 

Other possible uses of RSS-PHP

RSS_PHP has can be used to parse any form of RSS, from any accessible source. Other Integrations may involve

  • GeoRSS > JSON > AJAX > Google Maps API
  • Yahoo Web Search API in RSS
  • Torrent RSS

Or perhaps a combine some of the following RSS resources..

For more information view the RSS-PHP RSS Parser Introduction or go straight to the full RSS-PHP documentation; and to get started download the latest version of RSS-PHP for use in your PHP applications for free.

Valid XHTML 1.0 Strict

return to the top of the page