DOMDocument loadHTMLFile()被重新格式化

I have the following script:

$incldoc = new DOMDocument();

libxml_use_internal_errors(true);
$incldoc->loadHTMLFile($filename, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
libxml_use_internal_errors(false);

echo $incldoc->saveHTML();

Which loads this file:

<div monkey="123"></div>
<div>
    <h1>Hello!</h1>
</div>
<monkey>test</monkey>

When It gets output it looks like this:

<div monkey="123">
    <div>
        <h1>Hello!</h1>
    </div>
    <monkey>test</monkey>
</div>

Is there anyway for me to load the file without it getting formatted?

It's a little long, but how about:

$doc = new DOMDocument();
$doc->loadXML('<root/>');

$fragment = $doc->createDocumentFragment();
$fragment->appendXML(file_get_contents($filename));
$doc->documentElement->appendChild($fragment);

$html = implode(
    array_map(
        function($node) use ($doc) {
            return $doc->saveHTML($node);
        },
        iterator_to_array($doc->documentElement->childNodes)
    )
);

echo $html;