For a generalized solution such as ALL nodes that are empty, consider XSLT. Specifically, use an empty template (translated as copy or style nothing) matched to all nodes in document with * and conditions for text values equal to empty [.=''].
See XSLT Fiddle Demo using top PHP and XSLT StackOverflow users where each topusers node has at least one empty child, removed entirely in the result.
XSLT (save as .xsl)
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output version="1.0" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements="*"/>
<!-- Identity Transform to Copy Document as is -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Empty Template to Remove Empty Nodes -->
<xsl:template match="*[.='']"/>
</xsl:transform>
PHP (if needed enable php_xsl extension in .ini file)
// LOAD XML
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->load('Input.xml');
// LOAD XSLT
$xsl = new DOMDocument('1.0', 'UTF-8');
$xsl->load('XSLT_Script.xsl');
// INITIALIZE TRANSFORMER
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
// RUN TRANSFORMATION
$newXML = $proc->transformToXML($xml);
// SAVE NEW TREE TO FILE
echo $newXML;
file_put_contents('Output.xml', $newXML);
<br>(line break) tag.