I\'m trying to use the delete keyword to remove nodes from an xml file and it just plain won\'t work.
Here\'s a stripped down example of what I\'m working with. Eve
Yo
You need to do the 'for loop' in reverse. This goes for removing items in any collection/list via an iteration loop.
When an item is deleted (e.g. index 2 when j is 2), the next item in the List fills the space left by the deleted item (e.g. index 3 becmoes index 2), but j gets increased to 3, and the shifted item (in index 2) gets skipped. The following will work:
var _xmlList:XMLList=_sourceXML.i;
for (var j:int=_xmlList.length() - 1; j >= 0 ; j--)
{
if (_xmlList[j].deleteme == 1)
{
delete _xmlList[j];
}
}