を使用してHTMLページを解析しようすると、コードはこれまでのところ、私がしようとしていますが、それは私にエラーを示している。アンドロイド:困り、ここで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")まで行くと言いました。その後、それは固まって、logcatでjava.lang.nullpointerexceptionと言う。 私の質問はこれですか?JSoupはアンドロイドでもうまくいきますか? –