Thank's for spending your time on trying to solve this, It's hard to describe the problem in the title, so i will try to be more specific here :)
I'm having trouble deleting parent section (including children) only having the element value.
Example: I have a XML file. I loop threw it using XMLSlurper and store the parsed field element.
<fieldPermissions>
<editable>false</editable>
<field>Case.ClosedDate</field>
<readable>false</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Case.ClosedOnCreate</field>
<readable>false</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Case.ContactId</field>
<readable>false</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Case.Description</field>
<readable>false</readable>
</fieldPermissions>
So I store parsed fields in a map like this in map:
delList.put(file.name, [
fields: [Case.ContactId, Case.ClosedDate...], recordTypes: [], objects: []
])
The end result that I want is: For instance, I want to delete Case.ContactId, I store it in my delList map, but I don't know how can delete the whole parent section with all the children inside of it so the end XML file should look like this :
<fieldPermissions>
<editable>false</editable>
<field>Case.ClosedDate</field>
<readable>false</readable>
</fieldPermissions>
<fieldPermissions>
<editable>false</editable>
<field>Case.ClosedOnCreate</field>
<readable>false</readable>
</fieldPermissions>
//This was Case.ContactId section that i want to delete
<fieldPermissions>
<editable>false</editable>
<field>Case.Description</field>
<readable>false</readable>
</fieldPermissions>