【发布时间】:2012-12-20 15:45:47
【问题描述】:
Web 服务以XmlDocument 类型返回的 XML 中有几个 HTML 实体。在应用 XSLT 转换之前,我需要将它们替换为等效的 Unicode 字符。
XML 片段
<ics>
<record>
<metadata>
<meta name="Abstract" content="In the series of compounds observed after effect of &#947;-quanta"/>
</metadata>
</record>
</ics>
我在 .Net 4.0 中使用 C#。我尝试在上述 XmlDocument 的 OuterXml 属性上使用 HttpUtility.HtmlDecode,但它不会将 HTML 实体转换为 Unicode。
如何做到这一点?
编辑:
我看到应用 HtmlDecode 一次会得到 &amp;#947; 到 &#947;。如果我再次应用它,我会得到所需的 Unicode。
有更好的方法吗?
【问题讨论】:
-
在这里:stackoverflow.com/questions/8348879/decoding-all-html-entities 它说它应该可以工作。 “它不会将 [...] 转换为 Unicode”是什么意思?
标签: c# xml html-entities