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 will not only offer new tracks stripped of copy-protection software, it will let you remove DRM from your existing iTunes collection--for 30 cents per song.
Apple's latest software updates to iWork and iLife now integrate with various Web services including favorites like Facebook and Flickr.
Apple doesn't say no to two new telephony apps. But it won't say yes, either.
Microsoft server and tools boss Bob Muglia, who was named a divisional president on Monday covered a wide range of topics in a December interview with CNET News.
It only has a few posts on it, all from a single day last August, but it was apparently enough for Liskula Cohen to go after Google, which owns the publishing service used.
The company announces big changes to the iTunes Store as it shifts its pricing strategy.
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.
Beware links on the network purporting to offer nude shots of Knowles, Beckham, Ricci, Dunst, Hayek, and Hudson; they lead to malware, security researchers say.
Starting next week, the App Store download will incorporate functionality for Skype, Twitter, Google Talk, MSN Messenger, and Yahoo Messenger communications.
Watch this space for live updates from Apple's keynote presentation Tuesday inside San Francisco's Moscone Center, starring Phil Schiller.
Follow the companies that are shedding workers with this live layoff tracker, which we'll continue to update as more news surfaces.
TechSmith's Jing project graduates from its beta phase to a full paid product. $15 a year gets you enhanced video quality, no watermarks and exporting to YouTube.
Mischievous Internet forum 4Chan appears to have hacked into the popular Apple blog just as executive Phil Schiller took the stage at the Macworld Expo.
The paycheck is about to become Silicon Valley's hottest commodity, and the key to its resurgence.
The staff cuts hit its San Francisco and Moscow offices, the company confirms after a rumor on Gawker hinted at a much more significant layoff.
Investment firm Charles Schwab has updated its trading platform to make it easier for clients to find information and use that to their advantage.
Recycling program in United States expands recycling program from a trade-in credit system to no-strings checks. Consumers must pay for shipments, though.
In contrast to 2008, headlined by a slew of great titles and increasing popularity of gaming in general, the year ahead isn't shaping up to offer much industry excitement.
Holding "the key to growth in India," according to a market analyst, nearly 22 percent of small companies plan to pick up their first PCs in 2009.
Debate begins on the best policy for green-collar jobs, and Lotus says it may build an electric sports car to rival Tesla's.
Seven months before the first astronauts landed on the moon, Apollo 8 made a key round-trip into lunar orbit.

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>