【发布时间】:2013-12-30 08:45:58
【问题描述】:
我怎样才能只转义标签而不转义内容?让我举例说明...
这是原始的原始响应:
<GetWhoISResponse xmlns="http://www.webservicex.net">
<GetWhoISResult>Whois Server Version 2.0
To single out one record, look it up with "xxx", where xxx is one of the
of the records displayed above. If the records are the same, look them up
with "=xxx" to receive a full display for each record.
>>> Last update of whois database: Mon, 30 Dec 2013 08:20:00 UTC <<<
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
</GetWhoISResult>
</GetWhoISResponse>
如果我使用 StringEscapeUtils 和 unescape 文本 (unescapeXml):
<GetWhoISResponse xmlns="http://www.webservicex.net">
<GetWhoISResult>Whois Server Version 2.0
To single out one record, look it up with "xxx", where xxx is one of the
of the records displayed above. If the records are the same, look them up
with "=xxx" to receive a full display for each record.
>>> Last update of whois database: Mon, 30 Dec 2013 08:20:00 UTC <<<
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
</GetWhoISResult>
</GetWhoISResponse>
问题出在中间,在< 和> 被转义的那一行。我需要这个,因为我想把它转换成 JSON,但是现在我得到了解析错误。
【问题讨论】:
-
在检索到的 XMLish 数据的所有版本中 >> 是否保持不变,或者您是否正在寻找内容中特殊字符的通用解决方案?
-
我正在寻找一个通用的解决方案,因为我不知道会有什么反应。这只是我遇到的第一个问题:)
-
这是一个有趣的问题:)