com.xiaoleilu.hutool
类 HtmlUtil

java.lang.Object
  继承者 com.xiaoleilu.hutool.HtmlUtil

public class HtmlUtil
extends Object

HTML工具类

作者:
xiaoleilu

字段摘要
static String RE_HTML_MARK
           
static String RE_SCRIPT
           
 
构造方法摘要
HtmlUtil()
           
 
方法摘要
static String cleanHtmlTag(String content)
          清除所有HTML标签
static String encode(String text)
          转义文本中的HTML字符为安全的字符,以下字符被转义: ' with &#039; (&apos; doesn't work in HTML4) " with &quot; & with &amp; < with &lt; > with &gt;
static String removeHtmlTag(String content, boolean withTagContent, String... tagNames)
          清除指定HTML标签
不区分大小写
static String removeHtmlTag(String content, String... tagNames)
          清除指定HTML标签和被标签包围的内容
不区分大小写
static String restoreEscaped(String htmlStr)
          还原被转义的HTML特殊字符
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

RE_HTML_MARK

public static final String RE_HTML_MARK
另请参见:
常量字段值

RE_SCRIPT

public static final String RE_SCRIPT
另请参见:
常量字段值
构造方法详细信息

HtmlUtil

public HtmlUtil()
方法详细信息

restoreEscaped

public static String restoreEscaped(String htmlStr)
还原被转义的HTML特殊字符

参数:
htmlStr - 包含转义符的HTML内容
返回:
转换后的字符串

encode

public static String encode(String text)
转义文本中的HTML字符为安全的字符,以下字符被转义:

参数:
text - 被转义的文本
返回:
转义后的文本

cleanHtmlTag

public static String cleanHtmlTag(String content)
清除所有HTML标签

参数:
content - 文本
返回:
清除标签后的文本

removeHtmlTag

public static String removeHtmlTag(String content,
                                   String... tagNames)
清除指定HTML标签和被标签包围的内容
不区分大小写

参数:
content - 文本
tagNames - 要清除的标签
返回:
去除标签后的文本

removeHtmlTag

public static String removeHtmlTag(String content,
                                   boolean withTagContent,
                                   String... tagNames)
清除指定HTML标签
不区分大小写

参数:
content - 文本
withTagContent - 是否去掉被包含在标签中的内容
tagNames - 要清除的标签
返回:
去除标签后的文本


Copyright © 2014. All rights reserved.