Agustin Scalisi
Agustin Scalisi

Reputation: 551

get text with jsoup

I have this HTML

<ul id="items"><li>
                    <p><strong><span class="style4"><strong>Lifts open today include Agassiz to the top, Sunset, Hart Prairie, Little and Big Spruce from <br />
                    9 a.m. - 4 p.m.</strong></span></strong></p>
                  </li>
                  </ul>
                  <h3>&nbsp;</h3>
                  <h3>Trails Open<br />
                  </h3>
                  <ul id="items">

<li class="style4">
  <p><strong><span class="style4">100% of trails open with 30 groomed runs. </span></strong></p>
</li>
                  </ul>

I want the text "Lifts open today....."


This is my code. Nothing is show. There is no error in the logcat

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

            Elements div = doc.select("div.right");  
            for (Element liftope : div){
                Elements p =liftope.select("#items > li > p");
                liftoper = p.text();
            }

What is wrong???

Upvotes: 1

Views: 122

Answers (1)

DevOps85
DevOps85

Reputation: 6523

If you want only that text "Lifts open today include: Agassiz to the top, Sunset, Hart Prairie, Aspen and Little Spruce Conveyor!" this (i try) work:

Element div = doc.getElementById("contentinterior");
Elements uls = div.getElementsByTag("ul");
Element ul = uls.get(2);
String result = ul.text();

Upvotes: 1

Related Questions