title: Preserve New Lines when Using the PHP DOMDocument() Class
body: <p>I have HTML that looks like this when you view the source:</p>
  
  <h2>Original HTML</h2>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But after I do:</p>
  
  <pre><code>$dom = new DOMDocument();
  $dom-&gt;loadHTML($html);
  $dom-&gt;saveHTML();
  </code></pre>
  
  <p>My source code turns to this:</p>
  
  <h2>New HTML</h2>
  
  <pre><code>&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>How can I preserve new lines and white space when using the PHP DOMDocument() class and its methods?</p>