title: DOMDocument select only outer elements
body: <p>If I got a <code>DOMDocument</code> like this:</p>
  
  <pre><code>&lt;div name="outer"&gt;
      &lt;div name="inner"&gt;&lt;/div&gt;
      &lt;div name="inner"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div name="outer"&gt;
  &lt;/div&gt;
  &lt;div name="outer"&gt;
      &lt;div name="inner"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If I do <code>$dom-&gt;getElementsByTagName('div')</code>, I am going to get all 6 elements, including the inner ones. </p>
  
  <p>How can I for example select the second outer div element? (<code>name</code> is just to show what I mean, the elements don't have these propertys for real!)</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I know I could use <code>xpath</code>, but I am more likely looking for a solution without it as I am using only the DOMDocument functions in the rest of my code.</p>