hi i have big problem and i cant solve it myself please help i have something like this : var myXml:XML = new XML(); var newXml:XML = new XML(); myXml.onLoad = function(){ for(j=0;j<myXml.firstChild.childNodes.length;j++){ var element1:XMLNode = myXml.firstChild.childNodes[j]; newXml.appendChild(element1); } /* !!!! When i try to print output i get every second row :( WHY!? !!*/ for(i=0;i<newXml.childNodes.length;i++){ trace(newXml.childNodes[i]); } } myXml.ignoreWhite = true; myXml.load("data.xml"); structure of data.xml: <?xml version="1.0" encoding="windows-1250" standalone="no"?> <words label="lesson" > <word diff="0" /> <word diff="1" /> <word diff="2" /> <word diff="3" /> <word diff="4" /> <word diff="5" /> </words> Problem: /* When i try to print output i get every second row :( WHY!? */ How can
Your code looks ok. I believe - without testing - that the problem is here: var element1:XMLNode = myXml.firstChild.childNodes[j]; In each loop you create the same variable and flash do not like this. I would guess that by making this dynamic it would work. Something like: this["element"+j]=myXml.firstChild.childNodes[j]; Hope it will fix your problem :-)
Don't see what you're looking for? Try a search.
|