Parsing / extracting HTML table, website in Java

I want to parse the contents of this HTML table:

Blockquote

Here is the complete source code site:

http://www.kantschule-falkensee.de/uploads/dmiadgspahw/klassen/A_Klasse_11.htm

I want to analyze the data for each cell, all 5 cells under "Montag" (Monday) as an example. I tried several ways to parse this website using JSOUP, but I had no success. My main goal is to show the contents of a list in an Android app. At the moment, I tried to print the contents in the java console. Both languages ​​are accepted :). Any help is appreciated.

+4
source share
1 answer

Here are the steps you need to follow:

1) java- HTML:

2) Xpath helper

, 1: "//tr[1]//td[1]" , (1,1)

, 2: "/html/body[@class='tt']/center/table[1]/tbody/tr[4]/td[3]/table/tbody/tr/td" 15 Montag.

, 3: "/html/body[@class='tt']/center/table[1]/tbody/tr/td/table/tbody/tr/td" 380

jsoup

import org.jsoup.Jsoup;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        org.jsoup.nodes.Document doc = Jsoup.connect("http://www.kantschule-falkensee.de/uploads/dmiadgspahw/klassen/A_Klasse_11.htm").get();
        org.jsoup.select.Elements rows = doc.select("tr");
        for(org.jsoup.nodes.Element row :rows)
        {
            org.jsoup.select.Elements columns = row.select("td");
            for (org.jsoup.nodes.Element column:columns)
            {
                System.out.print(column.text());
            }
            System.out.println();
        }

    }
}
+11

All Articles