超鏈接我有Jsoup正從李
<div id = top1>
<div id topsub1>
<ul class="student">
<li>
<a href="/thomas">Tom</a>
</li>
</div>
<div id topsub2>
<ul class="student">
<li>
<a href="/thomas1">Tom1</a>
</li>
</div>
</div>
我想要得到的href和文本 所以我做 元素XX =選擇(DIV DIV UL LI)
當我做的foreach XX爲y,如果我做
string1 = y.text(); //這是打印Tom String2 = y.attr(「href」)//這總是空的。我無法得到/托馬斯? 我也試過y.attr(「a [href]」))
還有什麼是: doc.select(「。studentnames> a」);? 這是否意味着在ID = studentnames上獲得所有的「a」正確?
您的html代碼看起來與裸體的div搞砸了。考慮編輯這個並重新發布更有意義,更容易理解的html代碼。 –
感謝您的回覆我更新了 –