title: Getting multiple tables from HTML using Jsoup
body: <p>I am trying to scrape data from multiple tables on this website: <a href="http://www.national-autograss.co.uk/march.htm" rel="nofollow">http://www.national-autograss.co.uk/march.htm</a><a href="http://foo.com" rel="nofollow"></a></p>
  
  <p>I need to keep the table data together with their respective dates located in h2 so I would like a way to do the following:</p>
  
  <ul>
  <li>Find first date header h2</li>
  <li>Extract table data beneath h2 (can be multiple tables)</li>
  <li>Move on to next header and extract tables etc</li>
  </ul>
  
  <p>I have written code to extract all parts separately but I do not know how to extract the data so that it stays with the relevant date header. </p>
  
  <p>Any help or guidance would be much appreciated. The code I am starting with is below but like I said all it is doing is iterating through the data.</p>
  
  <pre><code>import java.io.IOException;
  
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  import org.jsoup.nodes.Element;
  import org.jsoup.select.Elements;
  
  
  public class Main {
  
  public static void main(String[] args) {
  
          Document doc = null;
          try {
              doc = Jsoup.connect("http://www.national-autograss.co.uk/march.htm").get();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          Elements elementsTable1 = doc.select("#table1"); 
          Elements elementsTable2 = doc.select("#table2");
          Elements dateElements = doc.select("h2");
  
          for (int i = 0; i &lt; dateElements.size(); i++) {
              System.out.println(dateElements.get(i).text());
              System.out.println(elementsTable1.get(i).text());
              System.out.println(elementsTable2.get(i).text());
  
          }
  
  }
  }
  </code></pre>