actionscript 3 - AS3 Delete child node from XML by child value -
i've got xml structure following;
<items> <item>5</item> <item>3006</item> <item>25</item> <item>458</item> <item>15</item> <item>78</item> </items>
how delete item value 458. clarify this, don't know index of item, calling delete items[index] won't here. have delete value.
any hints?
using e4x filtering , possibilities of using function inside filter can delete node want :
- xml.item.(text()==value) give node looking for
- valueof() give current node filtering
- delete delete node
so combining these infos can :
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());
Comments
Post a Comment