# Processing returned XML (AS 2.0/Flash 8)

**URL:** <https://forum.kirupa.com/t/processing-returned-xml-as-2-0-flash-8/273067>\
**Category:** flash\
**Created:** [October 10, 2008, 6:46pm UTC](https://forum.kirupa.com/t/processing-returned-xml-as-2-0-flash-8/273067 "2008-10-10T18:46:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![colorful\_tones](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/colorful_tones/32/3009_2.png) [@colorful\_tones](https://forum.kirupa.com/u/colorful_tones)\
**Post date:** [October 10, 2008, 6:46pm UTC](https://forum.kirupa.com/t/processing-returned-xml-as-2-0-flash-8/273067/1 "2008-10-10T18:46:16Z")

</div>

My brain is sizzling. I can smell it!  
I’m trying to figure our how to process the following XML structure:  
\<?xml version=“1.0”?\>  
\<links\>  
\<item type=“discussion”\>  
\<title\>My Wheels are round\</title\>  
\<link\>[http://www.esc.edu](http://www.esc.edu)\</link\>  
\</item\>  
\<item type=“schedule”\>  
\<title\>Saratoga New York\</title\>  
\<link\>[http://www.esc.edu](http://www.esc.edu)\</link\>  
\</item\>  
\<item type=“assignments”\>  
\<title\>Ride the Bus\</title\>  
\<link\>[http://www.esc.edu](http://www.esc.edu)\</link\>  
\</item\>  
\</links\>

so that I have categories of links designated by item type: assignments, schedule, discussion. These links are displayed in a vertical navigation of buttons that take to the specified link. However, each category does not appear unless the user clicks on a button to make the category’s links appear.

I’ve managed to get this far, but hit a major roadblock on the logic for the next step and suggestions are greatly appreciated!

// define basic variables for setting up the menu  
var item\_spacing = 28; // how far menu items are spaced veritcally  
var item\_count = 0; // counts menu items as they are added from the XML

// CreateMenu creates a menu based on the XML object passed.  
// It loops through all the items with a for loop adding clips to the menu\_mc  
// movieclip on the timeline, defining the appropriate text where needed  
function ProcessXML(menu\_xml){  
// start with the first item in the XML  
var items = menu\_xml.firstChild.childNodes;  
for (var i=0; i\<items.length; i++) {  
// only continue if the type of this item is a DISCUSSION  
if (items\*.attributes.type == “discussion”) {  
// create variables for our element  
var ftitle = items\*.firstChild; // same as items\*.childNodes[0]  
var link = items\*.childNodes[1]; // second child node

```
        // Create a menu item movie clip in the mcNavigation instance on the main timeline
        // for each item element offsetting each additional further down the screen
        var mcLink = mcNavigation.attachMovie("menuitem","item"+item_count, item_count);
        mcLink._y = item_count * item_spacing;
        item_count++;
        
        // assign text using nodeValue to get the text
        // from the text nodes and CDATA sections
        mcLink.mcText.text = ftitle.firstChild.nodeValue;
        mcLink.mcButton.location_text = link.firstChild.nodeValue;
        // set the onRelease of the item button to the DisplayInfo function
        mcLink.mcButton.onRelease = DisplayInfo;
    }
}

```

}

var myXML:XML = new XML();  
myXML.ignoreWhite = true;

myXML.onLoad = function(success:Boolean) {  
if (success) {  
ProcessXML(this);  
}  
else {  
trace(“Error loading XML file”); // no success? trace error (wont be seen on web)  
}  
}  
myXML.load(“navigation.xml”);
