我用的是jsoup-1.6.0,解析html标签字符串,只包含字符串内容“0”,但是jsoup返回null,我明白...
例如:
String html = "<span>0</span>";
Document doc = Jsoup.parse(html);
Elements eles = doc.getElementsByTag("span");
Element span = eles.get(0);
System.out.println(span.hasText());//false
System.out.println(span.ownText());//null, but I hope the result is "0"
这是为什么?
回答:
应该是bug,binary_runner说jsoup-1.3.3运行良好,我测试jsoup-1.5.2也运行良好。所以,我决定使用 jsoup-1.5.2 。
感谢 binary_runner!