the example of reference
var x1:XML = <x1>
<a id = "52">AYY</a>
<a>AYY 2 </a>
<b>BEE</b>
<c>CEE</c>
</x1>;
trace(x1.toXMLString());
trace("___________");
delete x1.a.@id;
trace(x1.toXMLString());
trace("___________");
delete x1.b;
trace(x1.toXMLString());
trace("___________");
delete x1.a;
trace(x1.toXMLString());
output
<x1>
<a id="52">AYY</a>
<a>AYY 2</a>
<b>BEE</b>
<c>CEE</c>
</x1>
___________
<x1>
<a>AYY</a>
<a>AYY 2</a>
<b>BEE</b>
<c>CEE</c>
</x1>
___________
<x1>
<a>AYY</a>
<a>AYY 2</a>
<c>CEE</c>
</x1>
___________
<x1>
<c>CEE</c>
</x1>
what if i only want to delete one element? or i want to delete the element which is and has no child element?
i can only use delete x1.a. ridiculous! i spend hours and couldn’t find a simple way .
var list:XMLList = x1.elements('a');
for each(var x:XML in list){
if(....){
//make something done
//i want to delete this x from the xml object.while keep other node untouched.
}
}
let me know the way you handle with this problem.
Its easy… take a look:
Output:
And you can even do this: