I have an xml file loaded, from which I want to remove elements that have no attributes or children, I'm trying to achieve something like this:
for child in root.find('targetElement'):
print(child)
if(len(child.attrib) < 1 and len(child) < 1):
root.remove(child)
But I guess the problem is that I'm finding the element then trying to remove it from the root element. Can someone please tell me how to do this?