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:

Ever wonder which movies are illegally downloaded the most? Using data collected by TorrentFreak, this infographic shows the top 10, starting with Avatar.
Verizon Wireless is planning a number of promotions, including a buy one, get one free Droid Razr offer, designed to goose sales. The Droid 4 will also be available Friday.
Rumors that HUD Google Glasses were in the works have now been confirmed--reportedly, a prototype has been seen and the glasses might even be available to people outside of Google.
Symantec's agreement to pay $50,000 to prevent the leak of source code for some of its flagship products was part of a "law enforcement investigation."
As Brazil's attorney general files an injunction to block tweets and suspend accounts of Twitter users warning people about speed traps, the question is will Twitter work with the Brazilian government and use its new tweet removal policy?
Rumor has it that Amazon is considering opening stores--the real, brick-and-mortar kind. Is that a good idea?
A woman accused of illegally downloading porn strikes back by claiming that it doesn't promote science or useful arts and therefore can't be copyrighted.
A new report from Bernstein Research attempts to gauge the long-term worth of Apple's "lifetime customers," those who will be back every few years to buy new versions of products.
The goal: A handheld device, described as a molecular-level Lego set, that will test for tuberculosis and similar bugs in 30 minutes.
Looking to cut down on those expensive heating bills during the winter months? The Hagent robot concept could help you do just that.
Trying to figure out which iPad games to buy with your hard-earned dough? Here's a look at our current top-30 favorites.
Starting tomorrow, PS3 and Vita owners will sign into a rebranded online service.
Watch out, Netflix. A new competitor will soon be entering the movie-streaming business. Verizon has announced it will team up with Coinstar, the parent of DVD rental company Redbox. CNET's Kara Tsuboi reports on the details of the partnership and why Netflix needs to worry.
Friskies kicks off a two-week Facebook marketing stunt with the Friskies Plus Playhouse, an interactive live video feed featuring 10 rescue cats playing with remote-controlled toys.
Flywheel grid storage company Beacon Power has been acquired for $30.5 million in a transaction that will return about 70 percent of a government loan.
Netflix snubs DVDs while Redbox doubles down on movie discs. Redbox gets more than 10,000 Blockbuster Express kiosks.
In a new charm offensive, Paramount Pictures says it's "humbled" by last month's protests over the Stop Online Piracy Act and Protect IP--and wants to talk.
According to a report from AppleInsider, oil field services provider Halliburton has decided to drop Research In Motion's BlackBerry platform in favor of Apple's iOS for its workforce.
Could Google be working on the "Project Tungsten" hardware first demonstrated at Google IO last year?
Police raid the home of MegaUpload's Kim DotCom wielding automatic weapons. Anonymous publishes the Social Security number of a sports promoter who disagrees with them. Are both sides hurting their causes by turning to increasingly tougher tactics?

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>