Jon*_*ley 11
该清洁剂会一直下降标签和保存文本.如果需要删除元素(即标记和文本/嵌套元素),可以预先解析HTML,使用remove()或删除元素empty(),然后通过清理器运行生成的结果.
例如:
String html = "Clean <div>Text dropped</div>";
Document doc = Jsoup.parse(html);
doc.select("div").remove();
// if not removed, the cleaner will drop the <div> but leave the inner text
String clean = Jsoup.clean(doc.body().html(), Whitelist.basic());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8516 次 |
| 最近记录: |