# XML: looping sickness

**URL:** https://forum.kirupa.com/t/xml-looping-sickness/133146
**Category:** Uncategorized
**Created:** [January 6, 2005, 2:21am UTC](https://forum.kirupa.com/t/xml-looping-sickness/133146 "2005-01-06T02:21:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Frg10](https://avatars.discourse-cdn.com/v4/letter/f/439d5e/32.png) [@Frg10](https://forum.kirupa.com/u/Frg10)
#### Post date: [January 6, 2005, 2:21am UTC](https://forum.kirupa.com/t/xml-looping-sickness/133146/1 "2005-01-06T02:21:30Z")

</div>

hi everyone! i must be out of my mind and cant find the problem: here is the script:

roleSelect = new XML();  
roleSelect.ignoreWhite = true;  
roleSelect.onLoad = function(success) {  
if (success) {  
roleLists = roleSelect.childNodes;  
hyt = 40;  
for (x=0; x\<roleLists.length; x++) {  
item = attachMovie(“tpLists”, “tpLists”+x, x);  
item.\_x = 0;  
item.\_y = hyt;  
hyt += 40;  
item.count.text = x+1;  
item.courses.text = roleLists[x].attributes.name;  
item.lessons.text = roleLists[x].attributes.lessons;  
item.quizzes.text = roleLists[x].attributes.quizzes;  
item.runTime.text = roleLists[x].attributes.runTime;  
if (roleLists[x].attributes.cType == “SCORM”) {  
tracer = new XML();  
tracer.ignoreWhite = true;  
tracer.onLoad = function(success) {  
if (success) {  
trace(“if SCORM, trace this”);  
[color=Red] **//Problem is here: why does the trace goes to the last item even if the valid item is the first?** [/color]  
traceNodes = tracer.firstChild.childNodes;  
for (xx=0; xx\<traceNodes.length; xx++) {  
findLink = traceNodes[xx].nodeName;  
if (findLink == “resources”) {  
item.link.text = traceNodes[xx].firstChild.attributes.href;  
}  
}  
}  
};  
tracer.load("…/Courses/"+roleLists[x].attributes.name+"/imsmanifest.xml");  
}else{  
item.link.text = “”;  
}  
}  
}  
};  
roleSelect.load(“TrainingPlan.xml”);

Geez… i dunno how to explain this :hangover:
