I want to extract(parse) a portion HTML document from an external website using php

For example: To extract news from yahoo, i tried using SimpleHTML DOM Parser from [sourceforge](http://simplehtmldom.sourceforge.net)

```
<?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->load_file($url);
$xxx=$html->find('title')->innertext; 
echo $xxx;
?>

```

> 
> Fatal error: Call to a member function find() on a non-object in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 1113
> 
> 
> 

---

Then I tried to echo the loaded html

```
<?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->load_file($url);
echo $html;
?>

```

Now I get:

> 
> Fatal error: Call to a member function innertext() on a non-object in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 1688
> 
> 
> 

---

I also tried using DOMDocument() through file\_get\_contents()

```
<?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->loadHTML($content);
$jjj=$doc->getElementsByTagName('title')->item(0);
echo $jjj;
?>

```

This throws up a very long list of Warnings. So let me just copy paste the first 10 alone

> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: no name in Entity, line: 166 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: expecting ';' in Entity, line: 166 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: no name in Entity, line: 256 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: expecting ';' in Entity, line: 256 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> 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
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: expecting ';' in Entity, line: 275 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: expecting ';' in Entity, line: 287 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: expecting ';' in Entity, line: 292 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]:
>  htmlParseEntityRef: expecting ';' in Entity, line: 311 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Attribute
>  class redefined in Entity, line: 325 in
>  /home/a1234bc/public\_html/simple\_html\_dom.php on line 37
> 
> 
> 

Can someone please point me to the right direction?