title: Remove empty XML tags with PHP but ignore tags with attributes
body: <p>I know its possible to remove empty XML tags using XPath (as seen here - <a href="https://stackoverflow.com/questions/8603237/remove-empty-tags-from-a-xml-with-php">Remove empty tags from a XML with PHP</a>)</p>
  
  <pre><code>$xpath = new DOMXPath($doc);
  
  foreach( $xpath-&gt;query('//*[not(node())]') as $node ) {
      $node-&gt;parentNode-&gt;removeChild($node);
  }
  
  $doc-&gt;formatOutput = true;
  echo $doc-&gt;savexml();
  </code></pre>
  
  <p>but is it possible to use a similar method to still remove empty tags but keep ones that have attributes?</p>
  
  <p>e.g.</p>
  
  <pre><code>&lt;range starts_at="2012-11-22" ends_at="2012-11-26"&gt;&lt;/range&gt;
  </code></pre>