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:

The tile-based user interface created for Windows Phone has moved to the core of Microsoft's consumer offerings. Now, Microsoft has to make sure it doesn't muddy Metro's clear design.
Intel and Advanced Micro Devices need to drop prices on their power-efficient chips to compete with ARM processor suppliers in the Windows 8 device market, says Asia-based publication.
With an iOS and now Android version of the note-taking app, Microsoft shows its app and service strategy can take precedence over its OS strategy.
World's tech capital adds 42,000 jobs in 2011, an increase of 3.8 percent compared with the nation's 1.1 percent growth rate, according to a new survey.
Acclaimed Cuban dissident blogger Yoani Sanchez has repeatedly tried to travel internationally but local authorities refuse to let her leave--human rights organizations think it's because of the political views she writes about on her blog.
Amazon moves one step closer to launching a standalone, subscription-based video streaming service with news of a possible partnership with entertainment giant Viacom.
The Web giant has some reassurances ready to go, Bloomberg reports. Good timing: European regulators are expected to rule on the companies' $12.5 billion merger by next week.
LinkedIn has supposedly acquired the startup Rapportive, which combines social networking with e-mail.
After large numbers of longtime 'Burners' failed to get tickets during the event's recent selection process, many claimed organizers had failed to adopt a sensible system. Now, those organizers are trying to calm community anger.
Apple's now requiring that developers upload the snazzier, Retina Display caliber screenshots of their games to the App Store when submitting their creations.
An Internet troll who posts allegedly hateful and racist remarks on Facebook's RIP sites, seems blase about his activities when he is intercepted by a BBC reporter.
The startup sees a 75 percent boost in efficiency with its LED bulb, a new material platform for bringing down the cost of LEDs for general lighting.
According to a report by the New York Times, Apple's voice-controlled personal assistant Siri accounts for nearly 25 percent of the traffic handled by search engine Wolfram Alpha.
While the PC market skids in the U.K. and France, Apple coasts to market share gains--possibly presaging a similar trend in the U.S.
The popular photo sharing app is rocked by news that it uploads contacts from iPhone users without permission.
If video game characters had Facebook profiles, they would take bathroom self-portraits and post party pictures just like the rest of us.
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 coexist 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.

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>