phpXML Home | XML Test Sandbox | RSS Feed Example | Flash-to-PHP Example

To see the source code for this sample, scroll to the below the feed listing or click here.

Feed URL: http://news.com.com/2547-1_3-0-5.xml

Select a technology news feed:

Toshiba shows off a two-wheeled autonomous robot than can roll over ramps and balance a tray of food. Wheelie might make a decent waiter.
As the Web generation descends on the South by Southwest Interactive show in Austin, several location-based start-ups try to put themselves on the map.
Hunch, a buzzy start-up that answers questions using crowdsourced recommendations, has lined up at least $10 million in funding, according to sources.
We might never know if a Twitter feed purporting to be by a woman left behind on her anniversary weekend by her SXSW-bound husband is real. But it's very funny stuff.
Federal Communications Commission Chairman Julius Genachowski lays out a plan for 21st century digital access, citizenship, literacy, and safety.
VoxOx's claim on a robust feature set makes it a powerful, if slightly unstable, multi-protocol chat and VoIP client--now with free universal translation for all IMs and tweets.
The case of a "runaway" Prius in San Diego demonstrates how claims about electronic flaws requires investigators to look carefully at the human element too.
A court decides to fine a man for offensive messages sent to his former lover on Facebook. What kind of precedent might this set?
Software giant's patch process speeds up after researcher releases code on Net that can be used to target the vulnerability and take over PCs.
Was it a glitch or a mischievous prankster who pulled the fire alarm during the South by Southwest Interactive Festival? Or maybe a sign that it's happy hour?
It's been four years since laptop computers passed desktops in U.S. unit sales. But laptop vendors can't rest, with the Netbook phenomenon sweeping the world and the iPad coming.
The annual interactive festival has only been under way for hours, but already the scene is full of energy--and lots of people.
Tim Cook will get $5 million plus some extra stock options as a reward for filling in for Steve Jobs last year.
In the search for cloud-based music storage, Microsoft has all the pieces to offer an unparalleled experience on Windows Phone 7.
Game developer and guru tells developers that if they want to create the next best seller, they need to get inside the player's head.
Marketers are everywhere at the annual digital-culture fest. It sort of makes your face start to melt a little bit.
Indexed DB isn't a sure thing, but it's got most of the right allies in the browser world to become an enabler of the cloud-computing vision.
A new FCC tool tests whether consumers are actually getting the broadband speeds they're paying for.
Site, which offers a breathtaking view of Paris, enables you to pan around, see monuments, and get a high-def feel for what the City of Light is all about.
EMC has unveiled a vision for globally federating data, essentially a cache for storage across wide area communication links.

Sample source code:
Please keep in mind that the code behind this actual page is a bit more complex than the code below because I wanted to be able to get a quick digest of technology feeds and wanted to make updating this page super easy. The actual code behind this page allows be to just type in a couple of properties for a new feed and the page automatically includes the new feed. The code below is a nice and simple version of what this page does. It's purpose is to help show you how quickly and easily the phpXML() class makes RSS aggregation possible.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
    <title>RSS Feed Sample</title>
</head>

<body>

<form name="theForm" method="post" style="margin:0px;padding:0px;">

<!-- this drop-down auto-submits to reload the new feed once a selection is made -->
<p>Select a technology news feed: 
<select name="feedID" onChange="submit()">
<option value="cnet"<?=$feedID == "cnet" " selected" "" )?>>CNET</option>
<option value="cnn"<?=$feedID == "cnn" " selected" "" )?>>CNN</option>
<option value="eweek"<?=$feedID == "eweek" " selected" "" )?>>eWeek</option>
<option value="reuters"<?=$feedID == "reuters" " selected" "" )?>>Reuters</option>
<option value="usatoday"<?=$feedID == "usatoday" " selected" "" )?>>USA Today</option>
<option value="bbc"<?=$feedID == "bbc" " selected" "" )?>>BBC</option>
<option value="wired"<?=$feedID == "wired" " selected" "" )?>>Wired</option>
</select></p>

</form>

<?php

include( "phpXML.class.php" );

// instantiate the new XML parser
$feed = new phpXML();

// our custom list of XML feed URLs
$feedList = array( 
    
"cnet" => "http://news.com.com/2547-1_3-0-5.xml",
    
"cnn" => "http://rss.cnn.com/rss/cnn_tech.rss",
    
"eweek" => "http://rssnewsapps.ziffdavis.com/tech.xml",
    
"reuters" => "http://today.reuters.com/rss/technologyNews/",
    
"usatoday" => "http://www.usatoday.com/repurposing/TechRss.xml",
    
"bbc" => "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/technology/rss.xml"
    
"wired" => "http://www.wired.com/news/feeds/rss2/0,2610,3,00.xml"
);

// if first time to this page (not here by submit), set the default feed to show
if( !empty( $_POST["feedID"] ) )
    
$feedID $_POST["feedID"];
else
    
$feedID "cnet";

echo 
"<p>Feed URL: " $feedList[$feedID] . "</p>\n\n";

// load the XML from the URL for the selected feed
$feed->load$feedList[$feedID] );

// parse out the title of this feed's source and its website URL
echo "<p>Title of Source: " $feed->childNodes[0]->childNodes[0]->findChildByName"title" )->value "<br/>\n" .
    
"URL for Source: " $feed->childNodes[0]->childNodes[0]->findChildByName"link" )->value "</p>\n\n";

echo 
"<div class=\"feedTrough\">";
// find all nodes in the tree named, "item" 
$items $feed->getAllByName"item" );
$feedLines = array();
// iterate through list of "item" nodes and get title, sub-title, and URL
foreach( $items as $item ) {
    
// find this item's "title" node
    
$head $item->findChildByName"title" );
    
// this this item's "link" node
    
$url $item->findChildByName"link" );
    
// and, finally, get the node named, "description"
    
$subhead $item->findChildByName"description" );
    
// echo it all out in whatever layout you like
    
echo "<div class=\"heading\"><a href=\"" $url->value "\" title=\"" $head->value "\">" $head->value "</a></div>\n";
    echo 
"<div class=\"subhead\">" html_entity_decode$subhead->value ) . "</div>\n\n";
}
echo 
"</div>\n";

?>


</body>

</html>