title: Scrape HTML & count children using Simple HTML DOM
body: <p>I'm trying to collect data from a website, and want to count the amount of elements in another element. Targeting different DOM elements works fine, but for some reason the $count variable in the example below stays at "0". I'm probably missing something really silly, but I can't seem to find it.</p>
  
  <p>The HTML on the website is as follows:</p>
  
  <pre><code>&lt;div id="list_options"&gt;
      &lt;div class="list_mtgdef_option pointer"&gt;
          &lt;div class="list_mtgdef_foildesc shadow"&gt;
          &lt;/div&gt;
          &lt;div class="list_mtgdef_stock tooltip"&gt;
              &lt;div class="list_mtgdef_stock_left"&gt;
                  &lt;span class="foil008469_1 block  "&gt;&lt;/span&gt;
                  &lt;span class="foil008469_2 block  transparency_25"&gt;&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class="list_mtgdef_stock_right"&gt;
                  &lt;span class="008469_8 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_7 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_6 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_5 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_4 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_3 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_2 block  "&gt;&lt;/span&gt;
                  &lt;span class="008469_1 block  "&gt;&lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And this is the php I'm using:</p>
  
  <pre><code>$array = array();
  
  foreach($html-&gt;find('#list_options .list_mtgdef_option') as $element) {
      $count = 0;
  
      foreach($element-&gt;find('.list_mtgdef_stock', 0)-&gt;childNodes(1)-&gt;childNodes as $node) {
          if(!($node instanceof \DomText))
              $count++;
      }
  
      $row = array(
          'stock' =&gt; strval($count)
      );
  
      array_push($array, $row);
  
  }
  echo json_encode($array);
  </code></pre>