0

I am reading data from my colleges website(html) using jsoup to display structured data in android app.

i am using this following code

Elements elements=doc.getElementsByClass("maintable").get(0).getElementsByTag("table").get(0).getElementById("table3").getElementsByTag("tbody").get(0).getElementsByTag("tr");

here is the image what i have to display enter image description here

html code is

<table border="0" align="center" cellpadding="0" style="width:101%;" class="maintable" id="table5">
        <tbody><tr class="parent" title="Please Click Here To View The Content">
        <td colspan="4" class="MTTD1" align="center"><b><u>Personal Details</u></b></td>

1 Answers1

0

Try this:

public class Test
{
    public static void main(String[] args) {
        String s ="<table border=\"0\" align=\"center\" cellpadding=\"0\" style=\"width:101%;\" class=\"maintable\" id=\"table5\">\n" +
                "        <tbody><tr class=\"parent\" title=\"Please Click Here To View The Content\">\n" +
                "        <td colspan=\"4\" class=\"MTTD1\" align=\"center\"><b><u>Personal Details</u></b></td>";
        Document doc = Jsoup.parse(s);
        Element elements = doc.select("table").first();
        for (Element element :elements.select("tr")){
            System.out.println(element.text());
        }
}

Output:

Personal Details
soorapadman
  • 4,451
  • 7
  • 35
  • 47
  • soorapadman check this question http://stackoverflow.com/questions/43001151/i-have-to-retrieve-data-from-html-table-using-jsoup – user7449462 Mar 24 '17 at 13:55
  • @user7449462 if you still didn't get the output share the HTML of the following question i ll update you with a answer – soorapadman Mar 27 '17 at 08:53