bug or feature: remove element doesn't work

When I remove an element I usually append it to a list called “garbage” and then use parent= element.getparent() parent.remove(element) This doesn’t work if the element is empty. It produces an error message saying that there is no parent. If I add some arbitrary child element to the element I want to remove, it works. If I load the XML document in oXygen and select the empty element, it will give me its correct path. So the empty element as a parent. Is this a quirk or am I doing something wrong?

Martin Mueller schrieb am 05.12.18 um 20:31:
I don't think it can be related to the element itself having a child or not. Are you sure it's not a missing *parent* of the element? I.e. you might be trying to remove the root element. Or, there could be duplicates in your "garbage" list and you might be trying to remove the element from its parent twice, which would then (obviously) fail the second time. Stefan

Martin Mueller schrieb am 05.12.18 um 20:31:
I don't think it can be related to the element itself having a child or not. Are you sure it's not a missing *parent* of the element? I.e. you might be trying to remove the root element. Or, there could be duplicates in your "garbage" list and you might be trying to remove the element from its parent twice, which would then (obviously) fail the second time. Stefan
participants (2)
-
Martin Mueller
-
Stefan Behnel