Using e4x filtering and the ability to use the function inside the filter, you can remove the node you want:
- xml.item. (text () == value) will give you the node you are looking for
- valueOf () will give you the current node you are filtering
- delete will delete node
combining this information you can do:
var xml:XML=<items> <item>5</item> <item>3006</item> <item>25</item> <item>458</item> <item>15</item> <item>78</item> </items>; function deleteValue(xml:XML, value:String):void{ xml.item.((text()==value) && (delete parent().children()[valueOf().childIndex()])); } deleteValue(xml, "458"); trace(xml.toXMLString());
source share