这是我目前的代码:
reader = new BufferedReader(new InputStreamReader(is));
String result = "";
while ((result = reader.readLine()) != null) {
System.out.println(result);
if (result.contains("<title>")) {
webtitle.setText(result.intern());
}
}
现在,我目前在TextView中得到的是:
<title>This is the website's title</title>
我想要的是:
This is the website's title
我需要更改什么来获取HtmlElement的内部文本?
答案 0 :(得分:0)
reader = new BufferedReader(new InputStreamReader(is));
String result = "";
while ((result = reader.readLine()) != null) {
System.out.println(result);
if (result.contains("<title>")) {
String tmp = result.intern();
int start = tmp.indexOf('>');
webtitle.setText(tmp.substring(start+1,tmp.substring(start).indexOf('<'));
}
}