Get # 1 with JSOUP?

I am creating an Android application that will extract text from a site and put it in TextView

.

Now I am stuck at this part where the application should get the string. This problem is specific because the string I am trying to extract is not in any tag.

Here is a sample source code for a web page.

Example of;an string
<!DOCTYPE html>
<html >
<head>
<title>Some title</title>
</head>
<body>
<form>
//Some code
    </form>
</body>
</html>

      

Now I want to get the first line Example of;an string

and put it TextView

in android.

+3


source to share


1 answer


The first line is not a valid HTML part, but it is part of the HTTP response body, so it should be available like this:



Response response = Jsoup.connect(url).execute();
String[] bodyLines = response.body().split("\n");
String firstLine = bodyLines[0];

      

+3


source







All Articles