title: DOMDocument : access the next following tag in PHP
body: <p>I have installed a JSON plugin and got the content of HTML page. Now I want to parse and find a particular table, which has only class, but no id. I parse it using the PHP class DOMDocument.I have the idea to access the tag before the table and after that somehow to access the next following tag(my table) using DOMDocument.
  Example:</p>
  <pre><code>&lt;a name=&quot;Telefonliste&quot; id=&quot;Telefonliste&quot;&gt;&lt;/a&gt;
  &lt;table class=&quot;wikitable&quot;&gt;
  </code></pre>
  <p>So, i get fist the <code>&lt;a&gt;</code> and after that I get <code>&lt;table&gt;</code>.</p>
  <p>I have got all the tables using the following commands and especially <code>getElementsByTagName()</code>. After that I can access item(2) where my table is:</p>
  <pre><code>        $dom = new DOMDocument();
  
  //load html source
  $html = $dom-&gt;loadHTML($myHtml);
  
  //discard white space
  $dom-&gt;preserveWhiteSpace = false;
  
  //the table by its tag name
  $table = $dom-&gt;getElementsByTagName('table');
          $rows = $table-&gt;item(2)-&gt;getElementsByTagName('tr');
  </code></pre>
  <p>This way is ok, but I want to make it more general, because now I know that the table is located in item(2), but the location can be changed e.g if a new table is included in the HTML page before my table. My table will not be in item(2), but in item(3). So, I want it it to parse in a way that I can still reach this table without changing something in my code. Can I do it using DOMDocument as a DOM parser?</p>