title: Load and Parse a portion of External HTML
body: <p>I want to extract(parse) a portion HTML document from an external website using php</p>
  
  <p>For example: To extract news  from yahoo, i tried using SimpleHTML DOM Parser from <a href="http://simplehtmldom.sourceforge.net" rel="nofollow">sourceforge</a></p>
  
  <pre><code>&lt;?php
  $url="http://news.yahoo.com/einsteins-brain-now-interactive-ipad-app-071441969.html";
  include('simple_html_dom.php');  
  $html=new simple_html_dom();
  $html-&gt;load_file($url);
  $xxx=$html-&gt;find('title')-&gt;innertext; 
  echo $xxx;
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>Fatal error: Call to a member function find() on a non-object in
    /home/a1234bc/public_html/simple_html_dom.php on line 1113</p>
  </blockquote>
  
  <hr>
  
  <p>Then I tried to echo the loaded html</p>
  
  <pre><code>&lt;?php
  $url="http://news.yahoo.com/einsteins-brain-now-interactive-ipad-app-071441969.html";
  include('simple_html_dom.php');  
  $html=new simple_html_dom();
  $html-&gt;load_file($url);
  echo $html;
  ?&gt;
  </code></pre>
  
  <p>Now I get:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function innertext() on a non-object in
    /home/a1234bc/public_html/simple_html_dom.php on line 1688</p>
  </blockquote>
  
  <hr>
  
  <p>I also tried using DOMDocument() through file_get_contents()</p>
  
  <pre><code>&lt;?php
  $url="http://news.yahoo.com/einsteins-brain-now-interactive-ipad-app-071441969.html";
  $content = file_get_contents($url);
  // echo $content works perfect
  
  $doc = new DOMDocument();
  $doc-&gt;loadHTML($content);
  $jjj=$doc-&gt;getElementsByTagName('title')-&gt;item(0);
  echo $jjj;
  ?&gt;
  </code></pre>
  
  <p>This throws up a very long list of Warnings. So let me just copy paste the first 10 alone</p>
  
  <blockquote>
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: no name in Entity, line: 166 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: expecting ';' in Entity, line: 166 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: no name in Entity, line: 256 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: expecting ';' in Entity, line: 256 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag
    fb:login-button invalid in Entity, line: 256 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: expecting ';' in Entity, line: 275 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: expecting ';' in Entity, line: 287 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: expecting ';' in Entity, line: 292 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
    htmlParseEntityRef: expecting ';' in Entity, line: 311 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
    
    <p>Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Attribute
    class redefined in Entity, line: 325 in
    /home/a1234bc/public_html/simple_html_dom.php on line 37</p>
  </blockquote>
  
  <p>Can someone please point me to the right direction?</p>