title: Python lxml - How to remove empty repeated tags
body: <p>I have some XML that is generated by a script that may or may not have empty elements. I was told that now we cannot have empty elements in the XML. Here is an example:</p>
  
  <pre><code>&lt;customer&gt;  
      &lt;govId&gt;
         &lt;id&gt;@&lt;/id&gt;
         &lt;idType&gt;SSN&lt;/idType&gt;
             &lt;issueDate/&gt;
             &lt;expireDate/&gt;
             &lt;dob/&gt;
             &lt;state/&gt;
             &lt;county/&gt;
             &lt;country/&gt;
      &lt;/govId&gt;
      &lt;govId&gt;
          &lt;id/&gt;
          &lt;idType/&gt;
          &lt;issueDate/&gt;
          &lt;expireDate/&gt;
          &lt;dob/&gt;
          &lt;state/&gt;
          &lt;county/&gt;
          &lt;country/&gt;
      &lt;/govId&gt;
  &lt;/customer&gt;
  </code></pre>
  
  <p>The output should look like this:</p>
  
  <pre><code>&lt;customer&gt;  
      &lt;govId&gt;
         &lt;id&gt;@&lt;/id&gt;
         &lt;idType&gt;SSN&lt;/idType&gt;        
      &lt;/govId&gt;        
  &lt;/customer&gt;
  </code></pre>
  
  <p>I need to remove all the empty elements. You'll note that my code took out the empty stuff in the "govId" sub-element, but didn't take out anything in the second. I am using lxml.objectify at the moment.</p>
  
  <p>Here is basically what I am doing:</p>
  
  <pre><code>root = objectify.fromstring(xml)
  for customer in root.customers.iterchildren():
      for e in customer.govId.iterchildren():
          if not e.text:
              customer.govId.remove(e)
  </code></pre>
  
  <p>Does anyone know of a way to do this with lxml objectify or is there an easier way period? I would also like to remove the second "govId" element in its entirety if all its elements are empty.</p>