I have a table

with this html code
<table class="grid"> <colgroup span="1" /> <colgroup width="7.1%" span="12" /> <tr><th>Year</th><th colspan="12">Month</th></tr> <tr> <td>2011</td> <td colspan="8"> </td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2011&month=9">Sep</a></td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2011&month=10">Oct</a></td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2011&month=11">Nov</a></td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2011&month=12">Dec</a></td> </tr> <tr> <td>2012</td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2012&month=1">Jan</a></td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2012&month=2">Feb</a></td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2012&month=3">Mar</a></td> <td><a href="https://www.gokgs.com/gameArchives.jsp?user=asdkk&oldAccounts=t&year=2012&month=4">Apr</a></td> <td colspan="8"> </td> </tr> </table>
I'm trying to parse the table and here is my code.
xml
<GridView android:id="@+id/gridview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numColumns="13"> </GridView>
Jsoup lib
try { Document verb = Jsoup.connect("https://www.gokgs.com/gameArchives.jsp?user=" + nickname + "&oldAccounts=y").get(); Element tableVerb = verb.select("p ~ table.grid").first(); Elements rowsVerb = tableVerb.select("tr"); titleList.clear(); for (int i = 0; i < rowsVerb.size(); i++) { Element row = rowsVerb.get(i); Elements cols = row.select("td"); for (Element e: cols){ if (e.hasAttr("colspan")) { int colspan = Integer.valueOf(cols.attr("colspan")); for (int y = 0; y < colspan; y++){ titleList.add(y, e.text().toString()); } } else { titleList.add(e.text().toString()); } } } } catch (IOException e) { e.printStackTrace(); }
As a result, I get the following table

My table has 13 columns (year + 12 months). If some months are missing in the table, then the <td colspan = "число"> </ td> tag is used in the html code.
At me all empty cells are added at first, and it is necessary to repeat the table from a site. Where is the mistake?