0
我已經下載jsoup並複製到/ libs,但我有一個大問題。我不知道解析這張表並從標籤中獲得價值。 我有這個表...JSOUP解析表
<table class="tabella-voli">
<thead>
<th>Compagnia</th>
<th>N.</th>
<th>Provenienza</th>
<th>Schedulato</th>
<th>Stimato</th>
<th>Stato</th>
</thead>
<tbody>
<tr style="background-color: rgba(253, 253, 253, 0.8);">
<td>RYANAIR</td>
<td>05021</td>
<td>Roma Ciampino</td>
<td>09/04/2014 13:10</td>
<td>09/04/2014 12:58</td>
<td>
<img src="/images/volo_green.gif" alt="Atterrato" title="Atterrato"/><br /> Atterrato </td>
</tr>
<tr style="background-color: rgba(253, 253, 253, 0.8);">
<td>RYANAIR</td>
<td>01411</td>
<td>Pisa</td>
<td>09/04/2014 17:50</td>
<td>09/04/2014 18:00</td>
<td>
<img src="/images/volo_green.gif" alt="In orario" title="In orario"/><br /> In orario </td>
</tr>
</tbody>
</table>
我想解析只有這個:
<td>RYANAIR</td>
<td>05021</td>
<td>Roma Ciampino</td>
<td>09/04/2014 13:10</td>
<td>09/04/2014 12:58</td>
<td>
和...
<td>RYANAIR</td>
<td>01411</td>
<td>Pisa</td>
<td>09/04/2014 17:50</td>
<td>09/04/2014 18:00</td>
<td>
,並打印成一個TextView。 這是我的代碼:
org.jsoup.nodes.Document doc = Jsoup.connect("http://mysite...").get();
Element tabella = doc.getElementsByClass("tabella-voli").first();
Elements tbody = doc.getElementsByTag("tbody");
Elements element = tbody;
System.out.println(element.text());
你能幫我嗎?對不起我的英語不好! 我是新手:) :) 謝謝你們!
對於每個'table.tabella-辦妥機票tr',檢查第一'td'的文本內容爲* RYANAIR *。如果是肯定的,請提取'tr'的其餘部分。 – MCL