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:

At Black Hat, a trio of security representatives from Mozilla detailed how the company plans to push the browser to be more secure for users while nudging developers toward safer coding practices.
RIAA wants to make sure nothing happens to Lime Wire' assets before courts decide how much the file-sharing service must pay in damages. Judge says assets aren't going anywhere.
A preliminary ruling rejected a claim that Intel's pricing practices hurt consumers.
CNET Car Tech gets to take the Nissan Leaf electric car for a preview drive.
Attackers exploiting a hole involving how Windows handles shortcut, or .lnk, files prompt Microsoft to rush out an emergency patch, well before its next scheduled Patch Tuesday.
Got a great idea for your own tech company? Today we're talking about how to make it a business, with two great guests: XMarks CEO James Joaquin, and Mahalo CEO (and This Week in Startups host) Jason Calacanis
Former Yahoo "Peanut Butter Manifesto" author Brad Garlinghouse is known for being colorful. At AOL, unlike Yahoo, he's confident that the company can do more than talk the talk.
So guess what Microsoft thinks of Yahoo Japan's decision to swap it out for Google as main search partner? Yeah, it's not too happy about it.
A woman calls Dell tech support to ask for help in locating pictures of herself on her computer. The pictures end up on a newly created Web site. She accuses the support representative of creating the site.
The quickly growing movie rental company is now bringing Blu-ray movies to its kiosks. They'll cost $1.50 per day.
BlackBerry maker will launch a tablet with similar dimensions as the iPad, but with Wi-Fi and Bluetooth capabilities only. To connect to the Web, the device has to be paired with a mobile phone.
Spirit, in electronic hibernation to endure a harsh Martian winter, has not phoned home since March 22, but engineers are hoping for a miracle from Mars.
Mozilla has given tabs some long-overdue love in the second Firefox 4 beta with App Tabs, a feature that annihilates your scramble to search for that one elusive open tab. Watch what it does in this How To video.
Soladigm, which adds thin films to glass to block light and heat, plans a manufacturing plant in Mississippi to make its green building gear.
Academics Jeff Jarvis and Danah Boyd, on stage at Supernova, can't pinpoint a solution to online privacy controversies, but agree misguided attempts to define privacy are part of the problem.
The company applied for a patent on mobile applications for booking flights and hotels, as well as mobile shopping services.
Google Ventures and CIA's investment arm fund Recorded Future, a start-up that monitors Web and connects dots between people, places, events, Wired says.
Copyright office says bypass is legal, while Wikileaks publishes classified documents on the war in Afghanistan. Also: New Apple desktops.
Uniloc USA is also suing Activision, Quark, others as follow-up to a similar suit filed against Microsoft over software activation tech.
Want to grab a quick panoramic picture with your iPhone? The makers of the popular RedLaser app have a new photo tool out that can create one using your iPhone's video camera.

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>