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 -->
The answer is that: You cannot use spaces in classnames. spaces are the seperaters of classes
if you have
<div class="container wrapper-something anothersomething"></div>
then you can use.container
,.wrapper-something
or.anothersomething
as a selector and you allways match that div.So in your code you have
<ul class="board List">
, so to get a match in a css-selector ($html->find('{here_comes_the_css_selector}');
) you can use eather.board
or.List
as the selctorTherefor your line
$board = $html->find('.board List');
should look more like this:With this syntax SimpleHTMLDOM finds elements with multiple class attribute
I solved it by removing board from the find parameter,as this:
now the parser seems to work correctly
With simple you would probably want to use:
If you really want to use:
Then use this one.