title: How to count all nodes in DOMDocument
body: <p>Using PHP 7.1 I want to count the number of nodes in the root of this string:</p>
  
  <pre><code>&lt;p&gt;Lorem&lt;/p&gt;
  &lt;p&gt;Ipsum&lt;/p&gt;
  &lt;div&gt;Dolores&lt;/div&gt;
  &lt;b&gt;Amet&lt;/b&gt;
  </code></pre>
  
  <p>Using following PHP:</p>
  
  <pre><code>$dom = new DOMDocument;
  $dom-&gt;preserveWhiteSpace = false;
  $dom-&gt;loadHTML($content);
  $root = $dom-&gt;documentElement;
  $children = $root-&gt;childNodes;
  var_dump($children)
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>object(DOMNodeList)#4 (1) {
    ["length"]=&gt;
    int(1)
  }
  </code></pre>
  
  <p>I don't understand why the string of HTML only returns as 1 node. Additionally, I am unable to iterate through the nodes.</p>