我使用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!
最佳答案
这是一个bug在 jsoup 1.6.0
中,由于新 HTML 解析器实现中的 null 检查不正确而导致。
我有fixed the issue它将在 1.6.1
中提供,我将在接下来的几天内提供。
关于java - 当Jsoup解析只包含 "0"的Html标签时,会返回null?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6464564/