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:

What better way to recover from the halftime show? More ads that continued to offer little in the way of originality of either strategy or execution. On the other hand, we had Clint Eastwood advertising Chrysler and Detroit.
Samsung's Super Bowl ad--for the Galaxy Note--claims that this is the product that can finally stop Apple fanboys from having to stand in line, waiting for Apple's latest.
Which tech company had the best first half ad in the Super Bowl? Here's a detailed analysis, written as it happened.
NASA looks to advanced design concepts to reduce noise and increase the fuel efficiency of future aircraft.
Sorry Steve, it's not post-PC, it's PC-plus, says IDC analyst Bob O'Donnell.
In an attempt to suggest that Chevy Volt's technology is more sophisticated than anything in the galaxy, Chevy's Super Bowl ad features aliens who don't just admire the Volt's advanced design.
Women around the world, fed up with Facebook's policy of not allowing breast-feeding pictures, are staging protests at Facebook offices and using Facebook to coordinate those efforts.
How many people will prefer watching 5 hours of model Adriana Lima on YouTube moving very, very slowly to the New York Giants defense moving very, very quickly? Or might people do both?
No, they won't, like Tom Brady, be viewing an illegal streaming site. Instead, Coke is using social media and the Web in order to have its polar bears react to the game as it's in progress.
You'll be drooling over the nonstop concept displays and projections in this video by the famous glassmaker.
In its Super Bowl spot, Doritos introduces Suzie, a cell phone personal helper with something of a temper.
The big Apple launch event was made for Steve Jobs. But now that he's not around, should Apple think of a different, more modern way of launching its products?
Silicon Valley startup Saygent crunches survey data and finds that picks for the big game may differ by political affiliation.
In an interestingly confident mix-up, the New York Giants' Web site not only announces that the team has already won, but offers winners' memorabilia for sale.
CNET Executive Editor David Carnoy looks at Sony's Playstation Vita through Apple goggles.
The National Science Foundation and the journal Science announce the 2011 winners of a contest to create the best visualizations in the fields of science and engineering.
The National Science Foundation and the journal Science announce the winners of last year's contest for the best visualizations in science and engineering.
The death of Micron Technology's CEO during a solo flight in a hard-to-handle aircraft symbolizes the risky memory chip market that is the company's bread and butter.
In a news conference, the New England quarterback mentions that while rehabbing last year in Costa Rica, he watched the big game on an illegal site. Is this the final validation for piracy?
Noise-reduction technology from a start-up called Audience accounts for the size of the iPhone 4S chip and keeps Siri off the iPhone 4, analyst Linley Gwennap concludes.

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>