I have this XML structure:
<numb>
<variable>
<name>john</name>
<age>12</age>
</variable>
<variable>
<name>janet</name>
<age>10</age>
</variable>
<variable>
<name>johanna</name>
<age>22</age>
</variable>
<variable>
<name>harry</name>
<age>24</age>
</variable>
</numb>
If I try to delete the variable with name johanna I do this:
delete numb.variable.(name=="johanna);
but then, I get this error:
"Error #1119: Delete operator is not supported with operand of type XMLList"
suggesting the numb.variable.(name==”johanna”) is an XMLList ..but then I tried this:
delete XML(numb.variable.(numb=="johanna");
but that didn’t delete anything..
Anyone knows how I could delete a certain variable in the numb XML?
You can retrieve the child nodes that have a different name from johanna and set those as the children nodes, using the setChildren() method.
e.g.
Another option is to loop through each node that satisfies the condition and delete the corresponding node through array access notation using the childIndex() method:
short version:
longer version: