preserveWhitespace = false; $dom->formatOutput = false; $dom->loadXML( ''.$src.'' ); $dom->normalizeDocument(); $src = $dom->saveXML(); return trim( preg_replace( '/>\s+<', $src ) ); } public function assertSameHtml( $expect, $actual, $message = null ){ return $this->assertSame( $this->normalizeHtml($expect), $this->normalizeHtml($actual), $message ); } }