简单的html dom无法正常工作,显示错误[关闭]

I am using simple html dom to parse html page..... This is my code..

include('simple_html_dom.php');


$html = file_get_html($my_url);


foreach($html->find('div') as $ul) {
     echo $ul;
   }

And i have also tried many other ways . Still i get this error. Error:

 Call to a member function find() on a non-object

I have tried out with other tags as well...

  $html->find('a');
  $html->find('h3');
  //But still same above error

Can anyone plz help me out wit the error..Thanks in advance

Well i found out the solution, The solution is:-

The latest version of simple_html_dom has got bugs in it.... So dont use simplehtmldom_1_5 file from sourceforge... Better use simplehtmldom_1_10 from sourceforge it works fine.

Bugs in simplehtmldom_1_5:-

Url of any site doesnt work here. You can give url of html file , but site url doesnt work It is not identifying ur object $html after reading the url....

Hope it helps people facing similar problem....

You are using cakephp so you can not use it as like this.

You either need to create vendor( for controller ) or create helper( for view ).

And one more $html is already reserved for $html helper.

For vendor loading

App::import('Vendor', 'HTMLDOM', array('file' => 'HtmlDom' . DS . 'simple_html_dom.php'));

For helper.

App::import('Helper', 'HtmlDom');
$NewHtmlDom = new SimpleHtmlDom; 

$fileContent = $NewHtmlDom->file_get_html($my_url);