Hi,

> Let me take some of that back, I was describing a different issue. I think 
> this might be related to parenting issues within XMLList. It can produce very 
> unexpected behavior. In this case, its adding a node to the original parent. 

Thanks for all that. The code isn't adding anything to the original list , it's 
looping though the nodes of a list then and adding them to a new collection.

var some:XMLListCollection = new XMLListCollection();
for each (var o:Object in  mainXML.item) { 
        some.addItem(o); 
} 

In this case mainXML is modified when it shouldn't be and ends up with 5 
elements instead of it's original 3. It certainly possible that when adding "o" 
it's parent is changed but not sure why that would result in duplicate items in 
mainXML.

And this code works correctly even though it is calling addItem with the same 
objects.

var some:XMLListCollection = new XMLListCollection();
for  (var i:int =0; i <  mainXML.item.length; i++) { 
        some.addItem(mainXML.items[i]); 
}

So why does using a loop index work, but using in doesn't?

Thanks,
Justin

Reply via email to