//一定要用索引,而且删除的对象要是XMLList里面的元素,不然会报错,或者不能删除 private function delNoVisibleNode(xmllist:XMLList):void { //for each (var item:XML in xmllist) for (var i:int=xmllist.length() - 1; i >= 0; i--) { var item:XML=xmllist[i]; if (item.@visible.toString() == "false" && item != null) { delete xmllist[item.childIndex()]; menuByVisibleFlaseXML.appendChild(item); //删除符合条件的子节点: delete xml.children()(@type == “car” && @color == “red”); } else if (item.@visible.toString() == "true") { if (item.hasComplexContent()) //有子节点 { arguments.callee(item.children()); //delNoVisibleNode(item.children()); } } } }