问题描述
我试图解析看到那里的表...
i'm trying to parse the table seen there...
我想是所有天(第一排)放入一个ListView。
what i want is to put all the days (the first row) into a ListView.
当我点击每天的ListView项我想显示当天下面列的数据,包括每个教室的时候...
When i tap the ListView item per day i want to show the data in the column below that day, including the time per classroom...
例如。在一排12:45 - 15时15 LBL130(ICT)
e.g. in one row: 12:45 - 15:15 LBL130 (ICT)
什么是做在Android的最佳方式?
What is the best way to do this on android?
推荐答案
这是你正在试图解析HTML可怕。但是你可以用JSoup使用正确选择器中选择了天。完整的选择器是表TBODY TR TD表TBODY TR TD字体
,但它可以缩短到身体GT;中心>表> TBODY> TR:LT(1)字体
This is horrible HTML you are trying to parse. But you can select the days with JSoup using the correct selector. The complete selector is table tbody tr td table tbody tr td font
but it can be shortened to body > center > table > tbody > tr:lt(1) font
.
Document doc = Jsoup.connect("http://www.novaprojecten.nl/roosters/lbl/basis/38/c/c00086.htm").get();
List<String> days = new ArrayList<String>();
for (Element col: doc.select("body > center > table > tbody > tr:lt(1) font")) {
days.add(col.text());
}
System.out.println(days); // Maandag 17-09, Dinsdag 18-09, Woensdag 19-09...
为了选择每天的内容,你将不得不解析每一行和每一只检索第n列。
In order to select contents for each day you will have to parse each row and retrieve only the n-th column.
这一切都是可以使用JSoup,回答你的问题。你应该看看并在的,为了进一步尝试自己的东西。
All this is possible using JSoup, to answer your question. You should take a look at their website and at the Selector documentation, in order to try further things yourself.
这篇关于在jsoup解析表(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!