Note that there are some explanatory texts on larger screens.

plurals
  1. POFind div with class using PHP Simple HTML DOM Parser
    text
    copied!<p>I am just starting with the mentioned Parser and somehow running on problems directly with the beginning.</p> <p>Referring to this tutorial:</p> <p><a href="http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/" rel="noreferrer">http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/</a></p> <p>I want now simply find in a sourcecode tne content of a div with a class ClearBoth Box</p> <p>I retrieve the code with curl and create a simple html dom object:</p> <pre><code>$cl = curl_exec($curl); $html = new simple_html_dom(); $html-&gt;load($cl); </code></pre> <p>Then I wanted to add the content of the div into an array called divs:</p> <pre><code>$divs = $html-&gt;find('div[.ClearBoth Box]'); </code></pre> <p>But now, when I print_r the $divs, it gives much more, despite the fact that the sourcecode has not more inside the div.</p> <p>Like this:</p> <pre><code>Array ( [0] =&gt; simple_html_dom_node Object ( [nodetype] =&gt; 1 [tag] =&gt; br [attr] =&gt; Array ( [class] =&gt; ClearBoth ) [children] =&gt; Array ( ) [nodes] =&gt; Array ( ) [parent] =&gt; simple_html_dom_node Object ( [nodetype] =&gt; 1 [tag] =&gt; div [attr] =&gt; Array ( [class] =&gt; SocialMedia ) [children] =&gt; Array ( [0] =&gt; simple_html_dom_node Object ( [nodetype] =&gt; 1 [tag] =&gt; iframe [attr] =&gt; Array ( [id] =&gt; ShowFacebookButtons [class] =&gt; SocialWeb FloatLeft [src] =&gt; http://www.facebook.com/plugins/xxx [style] =&gt; border:none; overflow:hidden; width: 250px; height: 70px; ) [children] =&gt; Array ( ) [nodes] =&gt; Array ( ) </code></pre> <p>I do not understand why the $divs has not simply the code from the div?</p> <p>Here is an example of the source code at the site:</p> <pre><code>&lt;div class="ClearBoth Box"&gt; &lt;div&gt; &lt;i class="Icon SmallIcon ProductRatingEnabledIconSmall" title="gute peppige Qualität: Sehr empfehlenswert"&gt;&lt;/i&gt; &lt;i class="Icon SmallIcon ProductRatingEnabledIconSmall" title="gute peppige Qualität: Sehr empfehlenswert"&gt;&lt;/i&gt; &lt;i class="Icon SmallIcon ProductRatingEnabledIconSmall" title="gute peppige Qualität: Sehr empfehlenswert"&gt;&lt;/i&gt; &lt;i class="Icon SmallIcon ProductRatingEnabledIconSmall" title="gute peppige Qualität: Sehr empfehlenswert"&gt;&lt;/i&gt; &lt;i class="Icon SmallIcon ProductRatingEnabledIconSmall" title="gute peppige Qualität: Sehr empfehlenswert"&gt;&lt;/i&gt; &lt;strong class="AlignMiddle LeftSmallPadding"&gt;gute peppige Qualität&lt;/strong&gt; &lt;span class="AlignMiddle"&gt;(17.03.2013)&lt;/span&gt; &lt;/div&gt; &lt;div class="BottomMargin"&gt; gute Verarbeitung, schönes Design, &lt;/div&gt; &lt;/div&gt; </code></pre> <p>What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload