如何使用Jsoup解析HTML文本? [英] How do I use Jsoup to parse html for text?

查看:164
本文介绍了如何使用Jsoup解析HTML文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Jsoup解析库来解析html文件,以使Tag与空白具有相同的作用?

How do I use the Jsoup parsing library to parse html files such that Tags should have the same effect as whitespace?

例如.

如果我使用Jsoup解析函数解析以下字符串

If I parse the below string using Jsoup parse function

word<br>one<br>is<br>one<br>word

我应该得到

word one is one word

而不是

wordoneisoneword

推荐答案

请在此处查看:

final String html = "word<br>one<br>is<br>one<br>word";
Document doc = Jsoup.parse(html);

String output = doc.text();

System.out.println(output);

输出:

word one is one word

这篇关于如何使用Jsoup解析HTML文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆