title: How to parse a specific table using Nokogiri?
body: <p>I am trying to pull the Name, Weight, and Shares Held table in the Holdings tab of this page: <a href="https://www.spdrs.com/product/fund.seam?ticker=DIA" rel="nofollow">https://www.spdrs.com/product/fund.seam?ticker=DIA</a></p>
  
  <pre class="lang-ruby prettyprint-override"><code># get table headers
  headers = []
  page.xpath('//*/table/thead/tr/th').each do |th|
    headers &lt;&lt; th.text
  end
  
  # get table rows
  rows = []
  page.xpath('//*/table/tbody/tr').each_with_index do |row, i|
    rows[i] = {}
    row.xpath('td').each_with_index do |td, j|
      rows[i][headers[j]] = td.text
    end
  end
  puts page.xpath("//table//tr//td[1]/text()")
  p rows
  </code></pre>
  
  <p>This is the code I have right now, and I'm not entirely sure how to do the xpath. The <code>puts page.xpath("//table//tr//td[1]/text()")</code> call returns all the labels for all the tables, but I only want the ones with the company names. How do I only choose that specific table's information, and how do I rewrite the loop to pull from that?</p>