title: PHP XPath Table elements disapearing
body: <p>I have just learned about XPath and I am wanting to read data from only certain columns in a table.</p>
  
  <p>My current code looks like this:</p>
  
  <pre><code>&lt;?php
  
  $file_contents = file_get_contents('test.html');
  
  $dom_document = new DOMDocument();
  
  $dom_document-&gt;loadHTML($file_contents);
  
  //use DOMXpath to navigate the html with the DOM
  $dom_xpath = new DOMXpath($dom_document);
  
  $elements = $dom_xpath-&gt;query("//tr[@class='rowstyle']");
  
  if (!is_null($elements)) {
      foreach ($elements as $element) 
      {
          echo $element-&gt;nodeValue . '&lt;br /&gt;';
      }
  }
  else
  {
      echo 'none';
  }
  
  ?&gt;
  </code></pre>
  
  <p>Also a variation in the query because through my research I have seen lots of issues with nest table elements but it produces the same result:</p>
  
  <pre><code>$elements = $dom_xpath-&gt;query("//table[@class='tablestyle']/tbody/tr[@class='rowstyle']");
  </code></pre>
  
  <p>It does grab the row of data but it makes into a single string, combining all of the cells into one string and making the  tags disappear.</p>
  
  <p>What I really want to do is separate those cells and grab the certain row number.</p>
  
  <p>I am also curious on how to find out which version of XPath I have... My PHP version is 5.3.5</p>