How Get The text on a separate line with JSOUP in Android?

92 views Asked by At

A part of my HTML in my site (http://example.com) is:

//if my HTML code is:
<div class="text-co">
    <div class="title">
        <a href="">00</a>
        <a href="">11</a>
        <a href="">22</a>
    </div>
</div>

<div class="text-co">
    <div class="title">
        <a href="">33</a>
        <a href="">44</a>
        <a href="">55</a>
    </div>
</div>

and my android code is:

String url = "http://example.com";
ProgressDialog mProgressDialog;

@Override
protected Void doInBackground(Void... params) {
    try {

        Document document = Jsoup.connect(url).get();

        Elements description = document.select("div[class=title] a");
            desc = description.text();

    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

and I want to show '00' in first line and '11' in 2th line and so on.
For example:
00
11
...

1

There are 1 answers

1
Sinh Phan On

try:

 Elements description = document.select("div[class=title]");
 Elements aTags = description.select("a");
 for(Element tag : aTags) {
    String value = tag.text();
 }

It's work with u?