//$Id: rss_parser.as,v 1.1 2003/05/18 16:30:12 filti Exp $ // declaring variables var channelTag = "channel"; var titleTag = "title"; var itemTag = "item"; function getElementsByTagName(xmlDoc, tagname, xmlObjArray){ var Nodes = null; if(xmlObjArray == null){ Nodes = new Array(); }else{ Nodes = xmlObjArray; } if(xmlDoc.hasChildNodes()){ for(var i=0; i < xmlDoc.childNodes.length; i++){ if( (xmlDoc.childNodes[i].nodeType == 1) && (xmlDoc.childNodes[i].nodeName == tagname)){ Nodes.push(xmlDoc.childNodes[i]); } getElementsByTagName(xmlDoc.childNodes[i], tagname, Nodes); } } return Nodes; } function myLoadHandler(success){ if(success && document.status == 0){ // retrieving the channel element, get the content of the title // tag and setting the textfield named "channeltitle" in our Movie var channel = getElementsByTagName(document, channelTag, null)[0] _level0.channeltitle = getTitleText(getFirstTitleElement(channel)); // retrieving all items from the rss file var itemsArr = getElementsByTagname(document, itemTag, null); // this the y-position for the first entry generated from items var yPos = 20; //iterating over the array for(var i=0; i < itemsArr.length; i++){ //place an instance of the symbol on the stage //Note: the third argument (depth) means the z level // in which the new movie is placed _root.attachMovie("itemtemplate", "clip" + i, i+10); with(eval("clip" + i)) { //setting the textfield of the new movie textfield = getTitleText(getFirstTitleElement(itemsArr[i])); // place the movie _y = yPos; //set the position for the next instance of the symbol yPos += _height; } } }else{ _level0.channeltitle = document.loaded + " " + document.status; } } //returns the node value of the first child of a node //assumption is: first child is a textnode and has a value function getTitleText(titleElement){ return titleElement.firstChild.nodeValue; } //returns the first node with tag title of a xml object function getFirstTitleElement(xmlObjArray){ return getElementsByTagName(xmlObjArray, titleTag, null)[0]; } var document = new XML(); document.onload = myLoadHandler; document.load("https://www.webreference.com/xml/index.rss");