0

tthis is my current code:

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());
    }
}

Now, what I currently get in my TextView is:

<title>This is the website's title</title>

What I want is:

This is the website's title

What do i need to change to grab what would be called the InnerText of the HtmlElement?

4

1 回答 1

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('<'));
    }
}
于 2013-09-07T18:20:30.427 回答