将 XML 中的 HTML 实体转换为 C# 中的等效 Unicode

its*_*lur 3 c# xml html-entities

我在 Web 服务作为类型返回的 XML 中有几个 HTML 实体XmlDocument。在应用 XSLT 转换之前,我需要将它们替换为等效的 Unicode 字符。

XML 片段

<ics>
 <record>
  <metadata>
    <meta name="Abstract" content="In the series of compounds observed after effect of &amp;#947;-quanta"/>
  </metadata>
 </record>
</ics>
Run Code Online (Sandbox Code Playgroud)

我正在使用 C# 和 .Net 4.0。我尝试使用上述 XmlDocument 的HttpUtility.HtmlDecode属性OuterXml,但它不会将 HTML 实体转换为 Unicode。

如何才能实现这一目标?

编辑:

我看到应用 HtmlDecode 一旦&amp;#947;到达&#947;. 如果我再次应用它,我会得到所需的 Unicode。

还有更好的方法吗?

Bar*_*chs 5

WebUtility.HtmlDecode在.NET 4.0中使用

\n\n

另外,&amp;#947;解码为&#947;逐字,而不是Unicode 字符\xce\xb3。主要问题是您的“HTML”不正确。您必须执行两次才能获得伽马字符。

\n