# 2 x "For" Loops with XML

**URL:** <https://forum.kirupa.com/t/2-x-for-loops-with-xml/179405>\
**Category:** flash\
**Created:** [February 19, 2006, 10:54pm UTC](https://forum.kirupa.com/t/2-x-for-loops-with-xml/179405 "2006-02-19T22:54:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![theSchtickler](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@theSchtickler](https://forum.kirupa.com/u/theSchtickler)\
**Post date:** [February 19, 2006, 10:54pm UTC](https://forum.kirupa.com/t/2-x-for-loops-with-xml/179405/1 "2006-02-19T22:54:56Z")

</div>

Hi there,

I got a issue trying to run 2 “for” statements within the one xml onLoad statement. I can’t see why it doesnt work, though it works fine when there is only one “for” statement. Here’s my code:

myXML.onLoad = function(ok) {  
if (ok) {  
allData = this.firstChild.childNodes;  
for (i=0; i\<allData.length; i++) {  
newBut = \_root.attachMovie(‘contentTemp’, ‘content’+i, i);  
newBut.\_y = -50;  
newBut.\_x = (i_30)+30;  
}  
allOtherData = this.childNodes[15].firstChild;   
for (k=0; k\<allOtherData.length; k++) {  
newBut = \_root.attachMovie(‘otherTemp’, ‘other’+k, k);  
newBut.\_y = -50;  
newBut.\_x = (k_20)+20;  
}  
} else {  
trace(‘error’);  
}  
};  
myXML.load(‘myText.xml’);

Are you simply not allowed to run two “for” statements at once? Any ideas?
