RSS_PHP RSS Parser Examples

The examples below are using RSS_PHP Free (v1) - the new more powerful RSS_PHP version 3 adds even more functionality.

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.

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