Search code examples
phphtmlsimple-html-dom

simple html dom - space in class name


I'm using PHP Simple HTML DOM to get element from a source code of a site (not mine) and when I find a ul class that is called "board List",this is not found.I think it might be a problem of space but I don't know how to solve it.

this is a piece of php code:

$html = str_get_html($result['content']); //get the html of the site
$board = $html->find('.board List');  //  Find all element which class=board List,but in my case it doesn't work,with other class name it works

and this is a piece of html code of the site:

<!-- OTHER HTML CODE BEFORE THIS --><ul class="board List"><li id="c111131" class="skin_tbl">
<table class="mback" cellpadding="0" cellspacing="0" onclick="toggleCat('c111131')"><tr>
<td class="mback_left"><div class="plus"></div><td class="mback_center"><h2 class="mtitle">presentiamoci</h2><td class="mback_right"><span id="img_c111131"></span></table>
<div class="mainbg">
<div class="title top"><div class="aa"></div><div class="bb">Forum</div><div class="yy">Statistiche</div><div class="zz">Ultimo Messaggio</div></div>
<ul class="big_list"><!-- OTHER HTML AFTER THIS -->


Solution

  • I solved it by removing board from the find parameter,as this:

    $board = $html->find('.List');
    

    now the parser seems to work correctly