这里一个HTML页面的代码到目前为止我想,但它显示了我的错误:的Android:需要帮助,试图解析使用JSoup解析器
URL url = null;
try {
url = new URL("http://wap.nastabuss.se/its4wap/QueryForm.aspx?hpl=Teleborg+C+(V%C3%A4xj%C3%B6)");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("1");
Document doc = null;
try {
System.out.println("2");
doc = Jsoup.parse(url, 3000);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("3");
Element table = doc.select("table[title=Avgångar:]").first();
System.out.println("4");
Iterator<Element> it = table.select("td").iterator();
//we know the third td element is where we wanna start so we call .next twice
it.next();
it.next();
while(it.hasNext()){
// do what ever you want with the td element here
System.out.println(it.next());
//iterate three times to get to the next td you want. checking after the first
// one to make sure
// we're not at the end of the table.
it.next();
if(!it.hasNext()){
break;
}
it.next();
it.next();
}
它打印System.out.println("3");
然后停止在此行
Element table = doc.select("table[title=Avgångar:]").first();
我怎样才能解决这个问题,
谢谢
最坏的事情是什么我甚至不能打印任何东西,我真的很感激,如果有人可以帮我打印一些东西,那么我会尽我所能来指定我的查询。 –
你遇到什么错误? –
好吧,正如我告诉它直到这一行System.out.println(“3”);然后它stucks和logcat它说java.lang.nullpointerexception 我的问题是这个JSoup适用于android以及? –