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:

A new version of Microsoft's operating system, bringing back that nebulous "Windows XP feel," won't wow anyone but will satisfy them on a much deeper level, ZDNet Australia writes.
Software from Q-layer is designed to help companies simplify the management and deployment of data center applications.
Phantom loads from shut-off electronics add up to a lot of wasted energy. Good for You, Good for the Planet says its technology cuts vampire energy to zero.
In these post-Wall Street meltdown, post-Bernie Madoff, post-bailout times, the reception to another filthy rich dot-commie will be lukewarm, at best
Scientists at Oxford University believe that the first thing you should do after you get your head kicked in (after calling 911) is to play Tetris.
Without Steve Jobs delivering his trademark keynote address, Macworld Expo won't likely make the same splash. But the show goes on, for now at least.
Financial software maker is attacking both online and offline money management.
One True Media, which makes the small-business-focused SpotMixer ad creation software, has also been named an "authorized reseller" for the video arm of Google's AdWords service.
The world's largest maker of Internet infrastructure equipment is now helping big media companies build social networking Web sites.
The Foundry Company gets the green light to go forward from the U.S. government.
review The new documentary, by two Israeli brothers, is an interesting look at the passion behind the millions-strong Mac community. But it lacks clarity.
Led by VP Phil Schiller, the Jobs-less presentation included a 17-inch MacBook Pro and DRM-free songs in iTunes.
Get keyboard shortcuts in Google's search with an unsanctioned Firefox add-on that brings more to the table than Google's own experimental shortcuts program.
Internet radio company, Pandora, has just released version 2.0 of its immensely popular iPhone application.
Want to find and follow friends on Twitter, but you don't know where to go to do it? Check out this list of six services that will help you do just that.
SanDisk and Samsung are introducing new solid-state drives for the Netbook and enterprise markets, respectively.
Community reviewer who suggested a chiropractor was less than honest in his billing practices is accused of defamation in a lawsuit.
UIQ Technology's interface has served many users well and will now transcend into the realm of smartphone history.
Google fended off a Chinese trademark infringement suit, and captured the sudden arrival of searches for characters that show a plane and two towers.
A courtroom lawyer who has sued individual file swappers in multiple federal courts is President-elect Barack Obama's choice for a top Justice Department position.
Tod Nielsen to become COO at virtualization company where he hooks up with former boss from his Microsoft days, VMware CEO Paul Maritz

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>