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:

Instagram has become the iPhone photo sharing app of choice, but cut through the hype and you'll find a compelling business lesson in managing scale through laser-like focus.
Charitable organization hopes credit card-size system can train a new generation of programmers worldwide.
LightSquared is asking the FCC to impose stricter standards on GPS equipment to ensure that its network can co-exist with these GPS devices.
Scanning Android apps for malware is a welcome move from a security standpoint, but Google still isn't going as far as Apple to eliminate the fragmentation issue.
HBO has invested $10 million into an Australian video rental service that operates much like Netflix, and right away, pundits say Time Warner is bowing to Netflix's business model. It's not that simple.
According to a study, a mere 6 percent of Americans would reduce toilet paper use in order to help the environment. Thirty-one percent, though, would give up books.
Yahoo Chairman Roy Bostock says that, along with three other board members, he's not seeking re-election this year. The company appoints two new board members to fill the gap.
The latest in Capcom's stellar survival-horror franchise hits the Nintendo 3DS. Is it the next must-own 3DS game?
Google is celebrating the 200th birthday of Charles Dickens with a doodle. But the doodle also seems to be trying to get you to use Google Books. Another example of Google's new commercialism?
The hacktivist group releases a document filled with private information on a group of City Hall and police department personnel. One councilwoman, whom Anonymous thanked for her community support, was spared.
Well, only in Russia, where telco MegaFon doled out prizes for those who used the most amount of data on its 3G unlimited data service.
New software for the Sleeptracker Elite wristwatch helps users track sleep data over time, including nightly sleep scores based on light sleep stages, minutes of interrupted sleep, and more.
Announced back in July, the Kinect Star Wars and special-edition Xbox 360 bundle will finally be available staring April 3.
The wireless carriers weathered the surge in calling and data traffic during the big game. Verizon Wireless says it shuttled 2.75 times as much data as during the previous Super Bowl, while AT&T says people actually uploaded more data than they downloaded.
Led by apps for mobile devices, the "app economy" is responsible for almost half a million jobs in the U.S., estimates a new study sponsored by CEO network TechNet. But the study also says figures may represent "jobs not lost."
The search giant has launched an online forum for folks to listen to some of the world's smartest people discuss breakthrough ideas that "live in the gray area between audacious projects and pure science fiction."

Wholesale retailer Sam's Club is rumored to be in talks with Apple to bring store-within-stores to Sam's Club warehouses.
With the Chrome for Android beta, Google adds PC sync, hardware acceleration, Web standards, and more as part of its plan "to reinvent mobile browsers."
Google is working on augmented-reality goggles, say goodbye to Blockbuster Express kiosks, and Redbox and Verizon team up to take on Netflix.
IT spending rose just 5 percent last year, but that small growth was seen in the face of economic problems across Europe and a hard-drive shortage, according to IDC.

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>