title: Select the next node of the selected node in PHP DOM?
body: <p>So far I'm working on a HTML file like this</p>
  
  <pre><code>&lt;div name="node"&gt;&lt;/div&gt;
  &lt;div&gt;&lt;/div&gt;
  &lt;div name="node"&gt;&lt;/div&gt;
  &lt;div&gt;&lt;/div&gt;
  &lt;div name="node"&gt;&lt;/div&gt;
  &lt;div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I want to select the next node of every "div" which has its name equal to "node" and I try :</p>
  
  <pre><code>$dom = new DOMdocument();
  @$dom-&gt;loadHTML($html);
  $xpath = new DOMXPath($dom);
  
  $els = $xpath-&gt;query("//div[@name='node']");
  
  $j = 0;
  
  foreach($els as $el)
  {
      if($el-&gt;next_sibling()) $j++;
  }
  
  echo $j;
  </code></pre>
  
  <p>But I just get an error</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined method DOMElement::next_sibling()</p>
  </blockquote>
  
  <p>Can anybody tell me what's wrong with my script please?</p>