title: Scraping data from the table using Xpath and PHP?
body: <p>I want to extract the data from the table below and the markup of the table is given below.I'm using Xpath to extract data from the table but other suggestions are also welcome.</p>
  
  <pre><code>      &lt;div style="clear:both;" id="showPrice"&gt;
        &lt;br&gt;
        &lt;table cellspacing="1"&gt;
           &lt;tbody&gt;
               &lt;tr&gt;
                   &lt;td width="50px" style="text-align: left" class="tdhead"&gt;SN&lt;/td&gt;
                   &lt;td width="650px" style="text-align: left" class="tdhead"&gt;Companies&lt;/td&gt;
                   &lt;td width="20px" class="tdhead"&gt;Trans&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt; Max Price&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt;Min Price&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt;Closing Price&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt;Total Shares&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt;Amount Rs.&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt;Prev. Closing&lt;/td&gt;
                   &lt;td width="20px" class="tdhead"&gt;Diff.&lt;/td&gt;
                   &lt;td width="50px" class="tdhead"&gt;Diff. %&lt;/td&gt;
                   &lt;td colspan="3" class="closing-price"&gt;
                       &lt;table&gt;
                           &lt;tbody&gt;
                              &lt;tr&gt;
                                 &lt;td colspan="3"&gt;365&amp;nbsp;days&lt;/td&gt;
                               &lt;/tr&gt;
                               &lt;tr&gt;
                                 &lt;td width="50px" class="closing-price-lighter"&gt;Max Price&lt;/td&gt;
                                 &lt;td width="50px" class="closing-price-lighter"&gt;Min Price&lt;/td&gt;
                                 &lt;td width="50px" class="closing-price-lighter"&gt;Avg&lt;/td&gt;    
                               &lt;/tr&gt;
                           &lt;/tbody&gt;
                       &lt;/table&gt;
                       &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr style="background-color: #A61A00"&gt;
                         &lt;td style="text-align: center;color:white;"&gt;1&lt;/td&gt;
                         &lt;td style="text-align: left;padding:3px;"&gt;
                            &lt;a href="viewcompany.php?symbol=ACEDBL&amp;amp;id=177" style="text-decoration:none;color:white;"&gt;Ace Development Bank Limited&lt;/a&gt;
                         &lt;/td&gt;
                         &lt;td class="numeric-data"&gt;3&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;269.00&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;264.00&lt;/td&gt;&lt;td class="numeric-data" style="background-color:#99CCFF;color:black;"&gt;264.00&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;495&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;131,405&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;265.00&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;-1.00&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99CCFF;color:black;"&gt;-0.38&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99FFFF;color:black;"&gt;281&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99FFFF;color:black;"&gt;102&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99FFFF;color:black;"&gt;150.15&lt;/td&gt;       
                     &lt;/tr&gt;
                 &lt;/tbody&gt;
              &lt;/table&gt;
           &lt;/div&gt;
  </code></pre>
  
  <p>I want only the data after the <strong>closing-price</strong> class. The data which I require is the text and the numeric value from the following <strong>td</strong> of the <strong>tr</strong>:</p>
  
  <pre><code>                       &lt;td style="text-align: left;padding:3px;"&gt;
                            &lt;a href="viewcompany.php?symbol=ACEDBL&amp;amp;id=177" style="text-decoration:none;color:white;"&gt;Ace Development Bank Limited&lt;/a&gt;
                         &lt;/td&gt;
                         &lt;td class="numeric-data"&gt;3&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;269.00&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;264.00&lt;/td&gt;&lt;td class="numeric-data" style="background-color:#99CCFF;color:black;"&gt;264.00&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;495&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;131,405&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;265.00&lt;/td&gt;
                         &lt;td class="numeric-data"&gt;-1.00&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99CCFF;color:black;"&gt;-0.38&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99FFFF;color:black;"&gt;281&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99FFFF;color:black;"&gt;102&lt;/td&gt;
                         &lt;td class="numeric-data" style="background-color:#99FFFF;color:black;"&gt;150.15&lt;/td&gt;       
                     &lt;/tr&gt;   
  </code></pre>
  
  <p>I tried following expression but could not get the result:</p>
  
  <pre><code>  //div[@id='showPrice']/td[preceding-sibling::td[@class='closing-price']]/text()
  </code></pre>