I am working with XML in ActionScript and trying to find a way to remove a node by providing the node reference.
Sample:
var node:XML =
<node>
<child a="1" b="2" c="3" />
<child a="2" b="2" c="3" />
<child a="3" b="4" c="3" />
<child a="4" b="2" c="6" />
</node>;
var targetChild:Xml = node.child.@(a==1)[0];
Currently, I am using the following to accomplish the removal of the node. Also I prefer not to iterate through the tree again or filter the nodes to find the targetChild i have already referenced.
delete (targetChild.parent().children()[targetChild.childIndex()]);
Somehow I just do not feel like it is a very clean way of doing it, but it works. I am wondering if there is another way to delete the node by reference?