title: XML remove nodes with no attributes or children
body: <p>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:</p>
  
  <pre><code>for child in root.find('targetElement'):
      print(child)
      if(len(child.attrib) &lt; 1 and len(child) &lt; 1):
          root.remove(child)
  </code></pre>
  
  <p>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?</p>