Read RSS Feeds on Your PSP

Read RSS Feeds on Your PSP

Use PHP and the web browser in the PSP's 2.0 system software to read RSS feeds.

The Sony PlayStation Portable (PSP) was a great device even before it got the killer addition of a built-in web browser. But now, with this addition, the game-playing, web-surfing, hip-pocket-size device is simply indispensable.

This hack creates a specially formatted RSS feed data page that displays nicely on a single page of the PSP screen.

The Code

Save the code in Figure as index.php.

An HTML RSS reader formatted for PSP
require_once( 'XML/RSS.php' );

function getValue( $node, $name )
	$nl = $node->getElementsByTagName( $name );
	return $nl->item(0)->nodeValue;

$feeds = array( );
$feeds []= array(
	'name' => 'Top Stories',
	'url' => ''
$feeds []= array(
	'name' => 'World',
	'url' => ''
$feeds []= array(
	'name' => 'U.S.',
	'url' => ''
$feeds []= array(
	'name' => 'Tech',
	'url' => ''

$feed = 0;
if ( isset( $_GET['feed'] ) ) $feed = $_GET['feed'];

ob_start( );
$ch = curl_init( );
curl_setopt($ch, CURLOPT_URL, $feeds[$feed]['url'] );
curl_setopt($ch, CURLOPT_HEADER, 0);

$rsstext = ob_get_clean( );

$cols = array( );
$cols []= "";
$cols []= "";
$cols []= "";
$col = 0;

$doc = new DOMDocument( );
$doc->loadXML( $rsstext );
$il = $doc->getElementsByTagName( "item" );
for( $i = 0; $i < $il->length; $i++ )
	$item = $il->item( $i );
	$title = getValue( $item, "title" );
	$link = getValue( $item, "link" );
	$description = getValue( $item, "description" );

	$html = "<p class='story'><a href=\"$link\">$title</a></p>";

	$cols[ $col ] .= $html;
	if ( $col >= 3 ) $col = 0;
<title><?php echo( $feeds[$feed]['name'] ) ?></title>
body { margin: 0px; padding: 0px; }
.link { font-weight: bold; margin-left: 10px; margin-right: 10px; }
<div style="width:478px;">
<div style="width:478px;border-bottom:1px solid black;margin-bottom: 5px;">
<?php $id = 0; foreach( $feeds as $f ) { ?>
<a class='link' href="index.php?feed=<?php echo($id); ?>">
<?php echo( $f['name'] ); ?></a>
<?php $id++; } ?>
<td valign="top" width="33%"><?php echo( $cols[0] ); ?></td>
<td valign="top" width="33%"><?php echo( $cols[1] ); ?></td>
<td valign="top" width="33%"><?php echo( $cols[2] ); ?></td>


The really interesting parts of this script are at the top, where the script finds the currently selected feed and downloads it using CURL. The script then uses the XML DOM system to parse up the RSS XML. Using getElementByTagName( ), it finds all of the item elements in the XML and stores their data into a set of column texts. Each column is specified by one entry in the $cols array.

The second half of the script outputs the list of possible RSS feeds, as well as the columns of article entries for the currently selected RSS feed, in an HTML format that fits nicely on a PSP screen.

Running the Hack

Upload the index.php file to the server and try the page first with Firefox. You should see something like Figure.

The RSS reader in Firefox

OK, that looks pretty good. Let's look at it on the PSP itself. Navigate to the URL by keying it into the address field. Then press the X button to fetch the URL. You should see something like Figure.

The RSS reader on the PSP

You can use the links along the top of the page to select the different categories of CNN news feeds. The links in the middle of the page go to the actual stories from the feed.

See Also

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows