How to parse ul li Tags using jsoup in android

后端 未结 1 1531
既然无缘
既然无缘 2021-01-06 05:49

i m trying to develop a College Updates android app using JSOUP API and parsing content from college website . How can i parse ul, li tags and display them .

sample

1条回答
  •  长发绾君心
    2021-01-06 06:21

    First you need to close all spans.
    Here's a short example:

    String html;
    html = "
    "; html += "
      "; html += "
    • M.Tech Exam Ian-2014 TimeTable 1
    • "; html += "
    • M.Tech Exam Feb-2014 TimeTable 2
    • "; html += "
    "; html += "
    "; //Document doc = Jsoup.connect("http://example.com/").get(); to load from url Document doc = Jsoup.parse(html); Elements div = doc.select("div.moduletable_events"); // select your div with yor class Elements ul = doc.select("div.moduletable_events > ul"); Elements li = ul.select("li"); // select all li from ul for (int i = 0; i < li.size(); i++) { Log.d("jsoup", " " + li.get(i).select("span > span").text()); } Log.d("jsoup", "size: " + li.size());

    0 讨论(0)
提交回复
热议问题