我有这段代码:
<div id="g4iloprop">
<h4>HF propagation conditions: <span class="date">2012 Sep 19 1205 UTC</span></h4>
<p><b><span title="10.7cm solar flux">Solar flux:</span></b> 104<img src="nc.gif" alt="no change" hspace="2" /> <b><span title="Mid-latitude A Index">A:</span></b> 8<img
请提示我取值</b> 104<img
感谢。
答案 0 :(得分:2)
试试这个:
String html = // your html here
Document doc = Jsoup.parse(html);
Elements elements = doc.select("b + img");
for( Element e : elements )
{
Node value = e.previousSibling();
// eg. print the node, here the output is 104 and 8
System.out.println(value.toString());
}
如果您只需要第一个值,则可以将for-Loop替换为:
Node value = elements.first().previousSibling();