title: How get first level of dom elements by Domdocument?
body: <p>How get first level of dom elements by Domdocument PHP?</p>
  <p>Example with code that not works - tooken from Q&amp;A:<a href="http://stackoverflow.com/questions/1540302/how-to-get-nodes-in-first-level-using-php-domdocument">How to get nodes in first level using PHP DOMDocument?</a></p>
  <pre><code>&lt;?php
  $str=&lt;&lt;&lt; EOD
  &lt;div id=&quot;header&quot;&gt;
  &lt;/div&gt;
  &lt;div id=&quot;content&quot;&gt;
      &lt;div id=&quot;sidebar&quot;&gt;
      &lt;/div&gt;
      &lt;div id=&quot;info&quot;&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id=&quot;footer&quot;&gt;
  &lt;/div&gt;
  EOD;
  
  $doc = new DOMDocument();
  $doc-&gt;loadHTML($str);
  $xpath = new DOMXpath($doc);
  $entries = $xpath-&gt;query(&quot;/&quot;);
  foreach ($entries as $entry) {
      var_dump($entry-&gt;firstChild-&gt;nodeValue);
  }
  ?&gt;
  </code></pre>