# For loop xml problem

**URL:** <https://forum.kirupa.com/t/for-loop-xml-problem/209288>\
**Category:** Uncategorized\
**Created:** [December 7, 2006, 3:26pm UTC](https://forum.kirupa.com/t/for-loop-xml-problem/209288 "2006-12-07T15:26:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![W84me](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/w84me/32/1257_2.png) [@W84me](https://forum.kirupa.com/u/W84me)\
**Post date:** [December 7, 2006, 3:26pm UTC](https://forum.kirupa.com/t/for-loop-xml-problem/209288/1 "2006-12-07T15:26:48Z")

</div>

Hi all!

I have this code which attach a movieclip and appends values to it.

I have a problem with the following line in bold red. It returns allways the last value from the xml file (allways the last id).

Thanks in advance.

```auto
var gamesData:XML = new XML();
gamesData.ignoreWhite = true;
gamesData.load("xml/games.xml");
gamesData.onLoad = function(bSuccess:Boolean):Void {
    if (bSuccess) {
        var xmlNode = this.firstChild.childNodes;
        var spacing = 210;
        var xPos = 0;
        var yPos = 0;
        for (var i = 0; i<xmlNode.length; i++) {
            var pictureLoader:MovieClipLoader = new MovieClipLoader();
            [COLOR=Red] **var id = xmlNode*.attributes.id;** [/COLOR]
            gHolder.attachMovie("game", "gameHolder"+i, gHolder.getNextHighestDepth());
            gHolder["gameHolder"+i]._x = (i%3)*spacing;
            gHolder["gameHolder"+i]._y = Math.floor(i/3)*90;
            pictureLoader.loadClip(xmlNode*.attributes.img, gHolder["gameHolder"+i].picture);
            gHolder["gameHolder"+i].gametitle.text = xmlNode*.attributes.gamestitle;
            gHolder["gameHolder"+i].gamedesc.text = xmlNode*.attributes.desc;
            [COLOR=Red]**gHolder["gameHolder"+i].onRelease = function() {
                getURL("games.php?id="+id+"", "_blank", "POST");
            };**[/COLOR]
        }
    } else {
        trace("error");
    }
};

```

and the xml:

```auto
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>

  <games>
  
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="1" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="2" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="3" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="4" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="5" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="6" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="7" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="8" />
    <game img="images/games/eikona1.jpg" gamestitle="dokimi" desc="ayto einai mia dokimi" id="9" />
    
  
  </games>

```
