Listing 1: Macromedia DesDev XML Document Structure
<?xml version="1.0" ?>
<macromedia_resources>
<resource type="Article">
<title>Sneak Preview Tips from DevCon 2002</title>
<author>Macromedia</author>
<url>http://www.macromedia.com/desdev/articles/sp_frontdoor.html</url>
<product name="ColdFusion" />
</resource>
<resource type="Article">
<title>Power Dreamweaver MX Tips</title>
<author>Joe Lowery</author>
<url>http://www.macromedia.com/desdev/articles/sp_jlowery.html</url>
<product name="Dreamweaver" />
</resource>
</macromedia_resources>
Listing 2: ColdFusion Component that pulls the Macromedia DesDev feed locally
<cfcomponent displayname="feeds">
<cffunction name="getDesDevFeed" access="remote" returntype="any">
<cfprocessingdirective suppressWhiteSpace="Yes">
<cfhttp url="http://www.macromedia.com/desdev/resources/
macromedia_resources.xml method="get" redirect="yes" timeout="10"/>
<cfheader name="Content-type" value="#cfhttp.mimeType#">
<cfreturn cfhttp.filecontent />
</cfprocessingdirective>
</cffunction>
</cfcomponent>
Listing 3: Flash ActionScript code to load and parse XML from the CFC
// include the necessary remoting classes
#include "NetServices.as"
#include "NetDebug.as"
// initialize the application only once
if(inited == null){
inited = true;
// display the loading message in the text field
body.text = "Loading content...";
// create the gateway url variable and set the defaultGatewayURL
var gwURL = "http://localhost/flashservices/gateway";
NetServices.setDefaultGatewayURL(gwURL);
// establish the connection to the gateway
gw = NetServices.createGatewayConnection();
// make reference to the feeds service
cfService = gw.getService("cfdj.feeds", this);
// call the getDesDevFeed method of the service
cfService.getDesDevFeed();
}
// handle the XML result passed from our CFC
function getDesDevFeed_Result(result) {
// create the XML object
var myXML = new XML();
// strip any whitespace in the XML
myXML.ignoreWhite = true;
// parse the XML
myXML.parseXML(result);
// set the length so we can enumerate through the XML nodes
var len = myXML.childNodes[0].childNodes.length;
var pointer = myXML.childNodes[0].childNodes;
// clear out the text field
body.text = '';
// loop through the xml nodes and populate the text field
for(var i = 0; i < len; i++) {
var title = pointer[i].firstChild.firstChild;
var author = pointer[i].firstChild.nextSibling.firstChild;
var url = pointer[i].firstChild.nextSibling.nextSibling.
firstChild;
body.htmlText += "<b><a href='" + url +
"' target='_blank'>"+
title + "</a></b> - by " + author + "\r\r";
}
}