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:

Apple-owned company on Tuesday releases next major version of its database product, FileMaker Pro 11.
But will consumers be willing to download and install yet another media player to play ScatterTunes' V-Albums?
Members of Congress announce the Global Internet Freedom Caucus and a bill to spend federal dollars on research to "defeat Internet suppression and censorship."
Ngmoco's Eliminate was one of the first games to offer 3G multiplayer on the iPhone. But how did they do it?
If you own a Kindle, you also own a mobile Web browser. But chances are you never use it. That may be about to change.
After all the hype, the TiVo Premiere was greeted by disappointment by many gadget fans. But is there more to the story?
HTC mobile device running Android was distributed by Vodafone with a botnet program on it, as well as Conficker and a password-stealing Trojan, Panda Labs says.
Cisco finally makes its big announcement--and it's a router. Plus, Sony 3DTVs are on the way, and is the Drudge Report spreading malware?
After complaints the original algorithm was not doing the job, Redmond fixes the code shuffling the order of the browsers in its ballot screen for European users.
New vulnerability in Windows and Office could allow an attacker to take control of IE 6 and IE 7 systems, software maker says.
Chuck Thacker, who helped pioneer key aspects of the PC, gets an honor seen as the Nobel Prize of computing. In an interview, he talks about the award, his work, and why he's not retiring anytime soon.
In heated war with rival Gowalla for the geek seal of approval at the annual digital culture festival, Foursquare unveils new badges, new partners, and new promotions.
An analyst report says that Apple gave plenty of warning that it intended to sue competitors it believed moved too close to iPhone's territory.
Dozens of companies are developing tools to get consumers involved in home energy management, but businesses are easier customers to serve, say smart-grid execs.
Austria's Guger Technologies is billing the device as the world's first commercial personal brain-machine speller.
The Electronic Frontier Foundation used the Freedom of Information Act to obtain a copy of the iPhone developer agreement from a federal agency and doesn't like what it found.
Samsung's $299 E6 eReader, which now has a tie-in with Barnes & Noble, is scheduled for an April or May release in the U.S.
Ad blocking is an easy scapegoat for the online media industry, but blocking ad-blocking will only stymie the evolution of the online media business.
Drudge says a Senate committee has falsely accused the conservative news aggregation site of spreading malware, but a CNET reader says it's true.
Chatroulette is receiving a lot of criticism, but perhaps the media are identifying it as something it's not.

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>