解析 html 字符串

来源:互联网 发布:使命召唤8mac版迅雷 编辑:程序博客网 时间:2024/06/06 04:30

http://www.open-open.com/jsoup/

 

去除html字符串内的html标签,只留文本:

/** * 解析一个html字符串,只得到此字符串中的文本 * @param html * @return */public static String html2txt(String html) {//<span style="color: rgb(229, 51, 51); background-color: rgb(0, 153, 0); font-weight: bold; font-style: italic; text-decoration: underline;">测试1</span>Document document = Jsoup.parse(html);String content = document.text();        return content;}