HTML特殊字符解析 [英] HTML speacial character parsing

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

问题描述

我正在寻找一个java类来解析所有的HTML特殊字符。
我想这是一个常见问题,但我现在找不到一个快速解决方案。



我想要得到的是:

 输入:th& egrave; - >输出:
输入:»
输入:& lraquo;
...

你知道对我有用吗?

解决方案

尝试StringEscapeUtils实用程序类。查看StringEscapeUtils.unescapeHtml()方法的文档。



这里的文档:

http://commons.apache.org/lang/api-release/在这里下载:

href =http://commons.apache.org/lang/ =nofollow> http://commons.apache.org/lang/

I'm looking for a java class to parse all HTML special characters. I guess it's a common problem but i cannot find a fast solution right now.

What i wanto to get is:

input: thè --> output: thè
input: »
input: &lraquo;
...

Do you know anything useful for me?

解决方案

Try the StringEscapeUtils utility class. Check the docs for the StringEscapeUtils.unescapeHtml() method.

Docs here:

http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html

Download here:

http://commons.apache.org/lang/

这篇关于HTML特殊字符解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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