Preventing DOMDocument from stripping white spaces after empty tags Preventing DOMDocument from stripping white spaces after empty tags php php

Preventing DOMDocument from stripping white spaces after empty tags


I know this is an old issue, and I was looking for the same thing when I came across this https://bugs.php.net/bug.php?id=50278

In the notes it says to pass LIBXML_HTML_NODEFDTD as an option like this:

$doc = new DOMDocument();$doc->loadHTMLFile($file, LIBXML_HTML_NODEFDTD);echo $doc->saveHTML();

This will keep the white space.