首页 > 其他分享 >解析 html 字符串

解析 html 字符串

时间:2023-02-19 11:01:16浏览次数:56  
标签:return String content html 字符串 解析 open


​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;
}


标签:return,String,content,html,字符串,解析,open
From: https://blog.51cto.com/u_21817/6066630

相关文章