I am having trouble with an xml loop. Here is my xml structure:
Code:
<myxml>
<item>
<name>Name 01</name>
<id>ID 01</id>
<colors>
<color>white</color>
<color>red</color>
</colors>
<width>100</width>
</item>
<item>
<name>Name 02</name>
<id>ID 02</id>
<colors>
<color>blue</color>
<color>purple</color>
<color>black</color>
<color>brown</color>
</colors>
<width>100</width>
</item>
</myxml>
Here is my "onload" function for this xml:
Code:
function xmlload() {
item = this.firstChild.childNodes;
num = item.length;
xplacering = 0;
for (var i:Number = 0; i < num; i++) {
itemname = item[i].firstChild.firstChild.nodeValue;
itemid = item[i].firstChild.nextSibling.firstChild.nodeValue;
itemcolors = ???// i need to attach mc's for "colors"..
itemwidth = item[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;
// attaching mc for each item
mymc = attachMovie("mymc", "mymc" + i, i);
mymc._y = 0;
xplacering = xplacering + mymc._width + 5;
mymc._x = xplacering;
}
}
There is no problem with item numbers.. I can attach movies for all, and i can trace name, id etc.. for each item.
But the problem is, i can't reach to colors.. I need to attach movies for each
color in every item.
I mean, i need to attach 2 movies for item named "Name 01" ( of course, i need to trace the color names ) and 4 movies for item named "Name 02" ( again trace the color names ).. I think it's easy but i am really confused. I will be pleased for any help.