我有一个试图从中挖掘Logname
价值的 HTML 页面。我可以将所有li
文本作为一个字符串组合在一起,但不是我想要的。我只想要li
.logname 之后的第二部分</span>
。有什么方法可以轻松搞定?有了我所拥有的,我可以进行拆分并得到我想要的,但似乎应该有一种更优雅的方式?
当前代码
Elements detail = mHtml.select ("div.alpha-first");
for (Element items : detail)
{
Log.d (TAG, " label text " + items.text());
detail.
if (items.text().equals ("ACID"))
{
Log.d (TAG, " got ACID ");
}
}
HTML
<html>
<title>emp id chart</title>
<body>
<div class="alpha-first">
<ul class="account-detail">
<li><span class="label">ID</span>42</li>
<li><span class="label">Logname</span>George</li>
<li><span class="label">Surname</span>Glass</li>
<li><span class="label">ACID</span>15</li>
<li><span class="label">Dept</span>101348</li>
<li><span class="label">Empclass</span>Echo</li>
</ul>
<p class="last-swipe">3 Apr 9:53</p><br> </div>
<div class="detail-last-loc">
<p style="font-size: 8pt;">Current status</p>
<p class="current-location">Bldg #23 South Lot</p>
<p> current time 10:43 <br /></p>
<div class="detail-extra">
<p><a href="/empswipe/history/151034842">More</a> | <a href="/empswipe/history/151034842/3">3 Day History</a></p>
</div>
</div>
</body>
</html>