how to scrape data from one table having same class in other table
<p>I have to scrape data and save it in .csv file from a web site which have many tables. I only scrape the data of one table having class marketData. But, there are two other tables having the same class. Currently my code is bringing all data from tables having class marketData. How can I scrape data from one table and skip other tables?
my code is as follows.</p>

<pre><code>public class ComMarket_summary {

boolean writeCSVToConsole = true;
boolean writeCSVToFile = true;
boolean sortTheList = true;
boolean writeToConsole;
boolean writeToFile;
public static Document doc = null;
public static Elements tbodyElements = null;
public static Elements elements = null;
public static Elements tdElements = null;
public static Elements trElement2 = null;
public static String Dcomma = ",";
public static String line = "";
public static ArrayList&lt;Elements&gt; sampleList = new ArrayList&lt;Elements&gt;();

public static void createConnection() throws IOException {
    System.setProperty("http.proxyHost", "191.1.1.202");
    System.setProperty("http.proxyPort", "8080");
    String tempUrl = "http://www.psx.com.pk/phps/mktSummary.php";
    doc = Jsoup.parse(new URL(tempUrl), 1000);        
    System.out.println("Successfully Connected");
}

public static void parsingHTML() throws Exception {

    for (Element table : doc.getElementsByTag("table")) {
        for (Element trElement : table.getElementsByTag("tr")) {
            File fold = new File("C:\\market_smry.csv");
            fold.delete();
            File fnew = new File("C:\\market_smry.csv");
            trElement2 = trElement.getElementsByTag("tr");
            tdElements = trElement.getElementsByTag("td");
            FileWriter sb = new FileWriter(fnew, true);

            if (table.hasClass("marketData")) {

                for (Iterator&lt;Element&gt; it = trElement2.iterator(); it.hasNext();) {
                    if (it.hasNext()) {
                        sb.append("\r\n");

                    }

                    for (Iterator&lt;Element&gt; it2 = trElement2.iterator(); it.hasNext();) {
                        Element tdElement2 = it.next();
                        final String content = tdElement2.text();
                        if (it2.hasNext()) {

                            sb.append(formatData(content));
                            sb.append("   ,   ");

                        }

                    }

                    System.out.println(sb.toString());
                    sb.flush();
                    sb.close();
                }
            }
            System.out.println(sampleList.add(tdElements));

        }
    }
}
private static final SimpleDateFormat FORMATTER_MMM_d_yyyy = new SimpleDateFormat("MMM d, yyyy", Locale.US);
private static final SimpleDateFormat FORMATTER_dd_MMM_yyyy = new SimpleDateFormat("dd-MMM-YYYY", Locale.US);

public static String formatData(String text) {
    String tmp = null;

    try {
        Date d = FORMATTER_MMM_d_yyyy.parse(text);
        tmp = FORMATTER_dd_MMM_yyyy.format(d);
    } catch (ParseException pe) {
        tmp = text;
    }

    return tmp;
}

public static void main(String[] args) throws IOException, Exception {
    createConnection();
    parsingHTML();

}
</code></pre>

<p>P.S: I am using JDK 1.8,Jre 1.8, jsoup 1.8.</p>