c# - 通过 System.Xml.XmlWriter 转义尖括号

标签 c# .net xml

我正在通过 System.Xml.XmlWriter 编写一个包含一些 XML 的字符串。我被困在使用 WriteString() 和文档中:

WriteString does the following: The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively.

我希望停止此操作,但我似乎找不到任何 XmlWriterSettings 属性来控制此行为。有哪些解决方法?谢谢!

大卫

最佳答案

尝试将您的真实内容包装在 CDATA 标签之间:

<![CDATA[ 这是我的内容 ]]>

关于c# - 通过 System.Xml.XmlWriter 转义尖括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66479/

相关文章:

c# - 使用 C# 设置 CertificatePolicy=$TrustAll

c# - 如何限制对其他公共(public)接口(interface)实现的内部接口(interface)的访问

c# - C# 中 XmlAttribute 开头的破折号

java - 使用不同的 Android 开关样式?

java - XML解析错误: UTF-8

c# - BigInteger 解析八进制字符串?

c# - 为什么 EF Core 在所需关系被清空时删除实体?

c# - MatDialog : controlling overall size regardless of content size

.net - 在服务器推送应用程序中维护.NET异步套接字连接

c# - 事件参数; "sender as Object"或 "sender as T"?