Avatar

Community Advisor

Hello Jonas,

 

I'm not sure this is a good way to delete child elements from a XML.

Can you try to user the removeChild method instead of 'delete' instruction ?

Here a code but I'm not 100% sure (because iterate and delete from a list is always not simple... but as I use the element and not the index for removeChild, it should work ?)

var allChilds = ctx.content.getElements('child');
for(var i=0;i<allChilds.length;i++){
 ctx.content.removeChild(allChilds[i])
}

Then you can add your new child.

Or if you want to replace a child, you can use 'replaceChild' function.

If it doesn't work I'll try on my side.

 

Cedric