title: Php DOMNode travelling
body: <p>I'm trying to parse an HTML document, and get text values from tags, but the problem is that the tags don't contain any special attributes or have some id's to target them.
  The only thing that can be anchored to - is another static text, used as Labels.</p>
  
  <p>The source page code looks similar to this</p>
  
  <pre><code> &lt;tr&gt;
  &lt;td&gt;
    &lt;span&gt; 
      Some text to link to
    &lt;/span&gt;
   &lt;/td&gt;
   &lt;td&gt;
    &lt;span&gt; 
      THE text to get
    &lt;/span&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  
  /*****************Parser Page Script*************************/
  $file = "src/src.htm";
  $doc = new DOMDocument();
  $doc-&gt;loadHTMLFile($file);
  
  /********* Page that Processes *********/
  //Pattern for regEx
  $pattern = "/Some text to link to/";
  
  $elements = $doc-&gt;getElementsByTagName('td');
  
  if (!is_null($elements)) {
  foreach ($elements as  $node){
    $text = $node-&gt;textContent;
  
   if(preg_match($pattern, $text, $matches)){
          echo "&lt;pre&gt;";
           print_r($node);
          echo "&lt;/pre&gt;";
  
       }
      }
     }
  </code></pre>
  
  <p>How to get the nextSibling value for searched td if the result is  [nextSibling] => (object value omitted)?</p>