问题描述
我的Atom供稿(UTF-8)中有一行XML,用省略号格式化,像这样。
<title type="html"><![CDATA[THIS WEEK IN HISTORY…]]></title>
要访问标题,我调用title.getText()
。
-
实际结果:
THIS WEEK IN HISTORY…
-
预期结果:
THIS WEEK IN HISTORY…
这是我的Title
课。
SimpleXML我在做什么错?
public static class Title {
@Attribute(name = "type", required = false)
String type;
@Text
String text;
public String getText() {
return this.text;
}
void setText(String text) {
this.text = text;
}
public String getType() {
return this.type;
}
public void setType(String _value) {
this.type = _value;
}
}
1楼
您的问题的解决方案是StringEscapeUtils.unescapeHtml4("…")
因此,将输出指定为“ ...” 提供unescapeHtml4()以将转换为在找到的
unescapeHtml4()将包含实体转义符的字符串转义为包含与转义符相对应的实际Unicode字符的字符串。 支持HTML 4.0实体。
2楼
来自Apache Commons Lang库的StringEscapeUtils.escapeHtml4()