private function stripComments(\DOMDocument $source)
    {
        $xpath = new \DOMXPath($source);

        foreach ($xpath->query('//comment()') as $commentNode) {
            $commentNode->parentNode->removeChild($commentNode);
        }

        return $source;
    }
private function stripComments(\DOMDocument $source)
    {
        $xpath = new \DOMXPath($source);

        foreach ($xpath->query('//comment()') as $commentNode) {
            $commentNode->parentNode->removeChild($commentNode);
        }

        return $source;
    }
private function stripComments ( \ DOMDocument $ source ) { $ xpath = new \ DOMXPath ( $ source ) ; foreach ( $ xpath -> query ( '//comment()' ) as $ commentNode ) { $ commentNode -> parentNode -> removeChild ( $ commentNode ) ; } return $ source ; }
This method remove all comments of an XML document.

@param \DOMDocument $source Document to be cleansed.

@return \DOMDocument
This method remove all comments of an XML document .