title: Simple HTML DOM load() returning null
body: <p>I am trying to extract everything from within the <code>&lt;body&gt;</code> tags of a normal HTML document. </p>
  
  <pre><code>function extractHtml($html){
  
      $doc = new simple_html_dom();
      $html = $doc-&gt;load($html);
  
      return $doc-&gt;find("body")-&gt;innertext;
  }
  </code></pre>
  
  <p>The <code>$html</code> being passed is a full HTML document, although when it is loaded using <code>load()</code> is returns null. This then obviously causes the find() to produce a notice </p>
  
  <blockquote>
    <p>Notice: Trying to get property of non-object </p>
  </blockquote>
  
  <p>What could be the reason for the load() returning null?</p>
  
  <p>In the past I have done;</p>
  
  <pre><code>function extractHtml($html){
      $dom = new DOMDocument();
      @$dom-&gt;loadHTML($html);
      $dom-&gt;preserveWhiteSpace = false;
  
      // get everything inside of &lt;body&gt;
      $body = $dom-&gt;getElementsByTagName('body');
      if($body &amp;&amp; 0&lt;$body-&gt;length) {
          $body = $body-&gt;item(0);
      }
  
      $search = array('&lt;body', 'body&gt;');
      $replace = array('&lt;div', 'div&gt;');
      return str_replace($search, $replace, $dom-&gt;saveHTML($body));
  }
  </code></pre>
  
  <p>Although I now need this to work in older versions of PHP to solve this error</p>
  
  <blockquote>
    <p>Warning: DOMDocument::saveHTML() expects exactly 0 parameters, 1 given</p>
  </blockquote>
  
  <p>Which was the reason for testing with simple html dom. </p>
  
  <p><strong>EDIT:</strong>
  When testing if I copy the example from the documentation by changing the HTML as follows, I still get the same error.</p>
  
  <pre><code>$doc-&gt;load("&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;");
  </code></pre>