# XML node links

**URL:** <https://forum.kirupa.com/t/xml-node-links/254294>\
**Category:** flash\
**Created:** [March 10, 2008, 5:15pm UTC](https://forum.kirupa.com/t/xml-node-links/254294 "2008-03-10T17:15:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crila](https://avatars.discourse-cdn.com/v4/letter/c/bb73d2/32.png) [@crila](https://forum.kirupa.com/u/crila)\
**Post date:** [March 10, 2008, 5:15pm UTC](https://forum.kirupa.com/t/xml-node-links/254294/1 "2008-03-10T17:15:38Z")

</div>

whats up kirupa! this is my first post! sweet!

anyway, i am having trouble with this code i have written. basically it loads in the XML, counts the nodes, then it parses the info for each node. i am having trouble assigning a link to each button. basically i want each button to load a new .swf that was specified in the XML. here is the code…

```auto

stop();

//LOAD XML & VARIABLES
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("boxes2.xml"));

function LoadXML(e:Event):void {
    xmlData = new XML(e.target.data);
    ParseBox(xmlData);
    XML.ignoreWhitespace = true; 
}
 
 
var cary = "products/1.swf";

//PARSE XML 
function ParseBox(boxInput:XML):void {
    
    var titleList:XMLList = boxInput.box.title;
    var desList:XMLList = boxInput.box.des;
    var linkList:XMLList = boxInput.box.link;
    
        for (var i:int = 0; i < titleList.length(); i++) {
            var boxr:MovieClip = new box();
            boxr.y = i * 100;
            holder.addChild(boxr);
            
            var titleElement:XML = titleList*;
            var desElement:XML = desList*;
            var linkElement:XML = linkList*;
            
            boxr.top.text = titleElement;
            boxr.bottom.text = desElement;
            cary = linkElement;
            
            boxr.addEventListener(MouseEvent.MOUSE_DOWN, clicker);
        }
}

//CLICKED ON BUTTON EVENT
function clicker (myEvent:Event) {
        startI();
        trace(cary);
    }

//LOAD .SWF
startI();

function startI() {
    var ldr:Loader = new Loader();
    var url:String = cary;
    var urlReq:URLRequest = new URLRequest(url);
    ldr.load(urlReq);
    inBox.addChild(ldr);
}

```

here is the XML…

```auto

<?xml version="1.0" encoding="UTF-8"?>

<boxes>

<box>
    <title>crappy</title>
    <des>dude</des>
    <link>products/1.swf</link>
</box>

<box>
    <title>crappy2</title>
    <des>dude2</des>
    <link>products/2.swf</link>
</box>

<box>
    <title>crappy3</title>
    <des>dude3</des>
    <link>products/3.swf</link>
</box>

<box>
    <title>crappy4</title>
    <des>dude4</des>
    <link>products/4.swf</link>
</box>

</boxes>

```

everything works except when you click on a button. the xml generated buttons accesses only the link information from my last node. so basically it keeps loading “products/4.swf” over and over again.

any help would be awesome! thanks in advance!
