title: Get children of document element through php domdocument parser
body: <p>Okay here is a very common xml parsing method, getting child nodes, but it's just not working how it should for me...</p>
  
  <p>I <em>CANNOT</em> get an array of childNodes from my root element here, but I can get it from any other node when they have children, that's not a problem. It's whenever I encounter getting childnodes from this document element that I can't seem to get more than just the very first child.</p>
  
  <p>I need to get all the first level nodes from document element..</p>
  
  <pre><code>$xdoc=createDOMDocument($file);
  $all_children= $xdoc-&gt;documentElement-&gt;childNodes;
  echo count($all_children);
  
  function createDOMDocument($file){
      $xdoc = new DOMDocument();
      $xdoc-&gt;formatOutput = true;
      $xdoc-&gt;preserveWhiteSpace  = false;
      $xdoc-&gt;load($file);
      return $xdoc;
  }
  </code></pre>
  
  <p>But this will only ever output "1", it doesn't find all the nodes, it always stops at the first node when I'm trying to output it. This makes no sense to me.</p>
  
  <p>The only node it ever finds below is: </p>
  
  <pre><code>&lt;title&gt;some title&lt;/title&gt;
  </code></pre>
  
  <p>If I delete that node, it will find topicmeta and so on, but never every node into an array which is what I need.</p>
  
  <p>Here's the XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;map title="mytitle" xml:lang="en-us"&gt;
  &lt;title&gt;some title&lt;/title&gt;
  &lt;topicmeta&gt;
  &lt;prodinfo&gt;
    &lt;prodname&gt;a product&lt;/prodname&gt;
        &lt;vrmlist&gt;
          &lt;vrm version="8.5"/&gt;
        &lt;/vrmlist&gt;
    &lt;platform/&gt;
  &lt;/prodinfo&gt;
   &lt;/topicmeta&gt;
    &lt;topichead navtitle="cat1" id="topichead4f53aeb751c875.38130575"&gt;
  &lt;topichead navtitle="another topic"/&gt;
  &lt;/topichead&gt;
    &lt;topichead navtitle="cat2" id="topichead4f53aeb3596990.18552413"/&gt;
    &lt;topichead navtitle="cat3" id="topichead4f52fd157487f9.21599660"/&gt;
  &lt;/map&gt;
  </code></pre>