PHP Simple DOM find not working -


this had me stuck while thought post it. issue find-> not working correctly , $product_name coming null

    require 'mysql_con.php';     require 'simple_html_dom.php';      $html = file_get_html('http://www.xxxx.com/index.php?main_page=index&cpath=23');      /* foreach($html->find('img') $element) {            echo $element->src . '<br>';          }    */      $find = $html->find('#specialslisting .specialslistboxcontents .indent a');      $i=0;      foreach ($find $test) {          $link = html_entity_decode($test->href);          $linkgrab = file_get_html($link);          $product_name = $linkgrab->find('#productname')->innertext;          echo $product_name;          break;      } 

as posting others, still unsure why below case , love if point out me.

i worked out issue :

$product_name = $linkgrab->find('#productname')->innertext;

should be

$product_name = $linkgrab->find('#productname', 0)->innertext;

basically product name has numbered. still bewildered because here: $find = $html->find('#specialslisting .specialslistboxcontents .indent a'); find command worked me find without need numbering, thought fact selector id have made unnecessary, if point out i'm missing great.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -