i am just starting with the mentioned parser and somehow running on problems directly with the beginning.
referring to this tutorial:
http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/
i want now simply find in a sourcecode tne content of a div with a class clearboth box
i retrieve the code with curl and create a simple html dom object:
$cl = curl_exec($curl);
$html = new simple_html_dom();
$html->load($cl);
then i wanted to add the content of the div into an array called divs:
$divs = $html->find('div[.clearboth box]');
but now, when i print_r the $divs, it gives much more, despite the fact that the sourcecode has not more inside the div.
like this:
array
(
[0] => simple_html_dom_node object
(
[nodetype] => 1
[tag] => br
[attr] => array
(
[class] => clearboth
)
[children] => array
(
)
[nodes] => array
(
)
[parent] => simple_html_dom_node object
(
[nodetype] => 1
[tag] => div
[attr] => array
(
[class] => socialmedia
)
[children] => array
(
[0] => simple_html_dom_node object
(
[nodetype] => 1
[tag] => iframe
[attr] => array
(
[id] => showfacebookbuttons
[class] => socialweb floatleft
[src] => http://www.facebook.com/plugins/xxx
[style] => border:none; overflow:hidden; width: 250px; height: 70px;
)
[children] => array
(
)
[nodes] => array
(
)
i do not understand why the $divs has not simply the code from the div?
here is an example of the source code at the site:
<div class="clearboth box">
<div>
<i class="icon smallicon productratingenablediconsmall" title="gute peppige qualität: sehr empfehlenswert"></i>
<i class="icon smallicon productratingenablediconsmall" title="gute peppige qualität: sehr empfehlenswert"></i>
<i class="icon smallicon productratingenablediconsmall" title="gute peppige qualität: sehr empfehlenswert"></i>
<i class="icon smallicon productratingenablediconsmall" title="gute peppige qualität: sehr empfehlenswert"></i>
<i class="icon smallicon productratingenablediconsmall" title="gute peppige qualität: sehr empfehlenswert"></i>
<strong class="alignmiddle leftsmallpadding">gute peppige qualität</strong> <span class="alignmiddle">(17.03.2013)</span>
</div>
<div class="bottommargin">
gute verarbeitung, schönes design,
</div>
</div>
what am i doing wrong?
the right code to get a div with class is:
basically you can get elements as you were using a css selector.
source: http://simplehtmldom.sourceforge.net/manual.htm
how to find html elements? section, tab advanced