How to pull Sharepoint list data into Flash using actionscript/XMLHTTP

I developed this as part of a project to retrieve and aggregate data from a sharepoint list and display in fields on a regional map of the US using flash for the UI.  This was in Sharepoint 2003 but will work in 2007 as well. 
The basic premise is to use XMLHTTP to obtain the data from your Sharepoint list, from Flash use the XML object in Actionscript to load the response XML and then parse through the XML using the XML DOM. 
//*****Begin configuration area **************
//*******General Configuration (Required for both portal and team sites**************
//change siteBaseURL to Sharepoint site URL
siteBaseURL = "http://[serveraddress]";
//valid values are portal or team
siteType = "team";
//List Id configuration
//update listid to appropriate list id in sharepoint
//to locate list id browse to sharepoint list and select modify columns/settings and
//copy listid from URL
 //change listId to image list GUID
listId = "{[listguid]}";
//*********Team Site Specific Configuration(Required for teamsites only************
//change site to site name in URL
site = "[sitename]";
 //*****End configuration area **************
//switch for whether this is a team or portal site to obtain the correct URL 
 if(siteType == "team")
   GetURL = siteBaseURL + "sites" + "/" + site + "/_vti_bin/owssvr.dll?Cmd=Display&List=" + listId + "&XMLDATA=TRUE";
   //GetURL = "";
 if(siteType == "portal")
   GetURL = siteBaseURL + "_vti_bin/owssvr.dll?Cmd=Display&List=" + listId + "&XMLDATA=TRUE";
myXML = new XML();
myXML.ignoreWhite = true;
function extractData(success){
rootNode = this.firstChild;
oNodeList = rootNode.childNodes;
wArray = new Array();
eArray = new Array();
cArray = new Array();
for(i = 0; i < oNodeList.length; i++)
  rsnode = oNodeList[1];
zNodeList = rsnode.childNodes;
 //sum attachment nodes
 for(i = 0; i < zNodeList.length; i++)
  zNode =  zNodeList[i];
  if(zNode.attributes.ows_Region == "West")
   attr = parseFloat(zNode.attributes.ows_Amount);
   num = new Number(attr);
   wArray[i] = num;
  if(zNode.attributes.ows_Region == "East")
   attr = parseFloat(zNode.attributes.ows_Amount);
   num = new Number(attr);
   eArray[i] = num;
  if(zNode.attributes.ows_Region == "Central")
   attr = zNode.attributes.ows_Amount;
   num = new Number(attr);
   cArray[i] = num;
_root.westText.text = FormatAsDollars(sumAttributes(wArray));
_root.centralText.text = FormatAsDollars(sumAttributes(cArray));
_root.eastText.text = FormatAsDollars(sumAttributes(eArray));
function sumAttributes(aArray)
 tNum = new Number();
 for(x = 0; x < aArray.length; x++)
  xNum = new Number(aArray[x]);
  tNum = tNum + xNum;
 return tNum;
function FormatAsDollars (amount, isCents) {
// Make sure we’re given a real number to work with: 
   if (isNan(amount)) {
     return NaN;
// Convert everything to cents. A float is assumed to be
// dollars-and-cents, while an integer is assumed to be in
// dollars unless an "isCents" argument is added to the call. 
   if (isCents != "isCents") {
     amount = amount*100;
     amount = Math.round(amount);
// Handle less-than-a-dollar single-digit and double-digit cases:  
   amount = String(Math.floor(amount));
   if (amount.length == 1) {
     return ("0.0"+amount);
   if (amount.length == 2) {
     return ("0."+amount);
// First grab the last two characters as cents, and remove them
// from the amount string:
   cents = amount.slice(-2);
   amount = amount.substring(0, amount.length-2);
// Now stuff the last three digits at a time into an array, removing
// them from the string. (We have to work backwards to figure where
// commas should go.)
   dollars = [];
   do {
     amount = amount.substring(0, amount.length-3);
   } while (amount.length>3);
// If there are 1 or 2 numbers remaining, they’ll need to be at
// the front of the number, with their own comma. (We need to test
// to make sure we don’t end up with $,123.00 or such.)  
   if (amount.length) {
// Now reverse the array, so the last elements appear first:  
// Finally construct the return string. The "join()" function turns
// an array to a comma-delimited string.  
   //return ("$"+ dollars.join() + "." + cents);
   //modify to format return format output
   return (dollars.join());
//author Rod Stagg January 2005 

How to request data from a Sharepoint list via XMLHTTP and pass a parameter to the XSL for processing

Requirements: make sure the MS XML parser is available on the server.
FYI: check out the client-side API in the latest Sharepoint SDK-pretty cool stuff.
I didn’t drop the links.xsl but it’s easy enough to create your own to fit your situation-just open the URL below in the browser to access the XML and locate the fields you want to render in your XSL i.e. @ows_LinkFilename"> etc. 
I developed this as part of a project to provide the ability to pull mp3 audio files stored in a sharepoint document library, group them by sub-folder (hence the need to pass parameters to the XSL for handling child lists, and wire up the Windows Media Active X player to launch the audio files from Sharepoint-all using client-side code only.  RJS.
function getLinks(){
// Load XML
var xhr = new ActiveXObject("Msxml2.XMLHTTP.3.0");
var doc = xhr.responseXML;
var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
var xslProc;
var nodeBook, sIdValue;
xslDoc.async = false;
if (xslDoc.parseError.errorCode != 0) {
   var myErr = xslDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   xslt.stylesheet = xslDoc;
   var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async = false;
xmlDoc.validateOnParse = false;
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
      xslProc = xslt.createProcessor();
      xslProc.input = xmlDoc;
      var pfolder = ‘http://%5Bserveraddress%5D/sites/%5Bsitename%5D/Shared%20Documents/';
     xslProc.addParameter("pfolder", pfolder)
return xslProc.output;

Can’t believe Sharepoint is finally taking off

Who would have thought back in 2000 when I dug up this little known download MS called the digital dashboard resource kit that this would end up being a 800 million dollar product for MS?  Countless Sharepoint implementations later and I still find it funny how somehow I can never escape Sharepoint-wherever I go-Warning to others" once people know you know sharepoint there is no escape. 
Not sure why Sharepoint has become my career fate-is it a calling?  Not even sure why I have had so much success with Sharepoint over the years-somehow when you are blesssed/cursed with the Sharepoint calling it just all makes sense-a little information architecture here, a dab of a sensible site structure and navigation there, a splash of SEO and meta-tagging, and of course don’t forget the users-what’s important to them since just because you build it doesn’t mean they will come.
It’s also funny watching people recent to the technology-watching them go through the discovery process of working with the product-at first the naive joy that this is so easy-why do we even need developers?  Heck, now I am a developer:)  This is soon followed by a slightly more realistic outlook once the requests for customization start rolling in-the frenzy to find solutions begins and the honeymoon stage is nearing it’s end.  
I notice in the current release MS made an effort to provide tons of documentation unlike the old days when the SDK and a prescriptive architecture guide were the sharepoint person’s only crutches.  It’s interesting to hear from newbies-have you seen this link, document etc. and hear the joy that "hey if I follow these guidelines I will be ensured of a successfull Sharepoint project"  Poor souls indeed. 
The next phase?  I will dive into this on the next post but here is a teaser:  why I hate the content editor web part.