【问题标题】:Can not load XML document containing @ entity [duplicate]无法加载包含 @ 的 XML 文档实体[重复]
【发布时间】:2016-11-15 23:27:22
【问题描述】:

请告诉我如何解决这个问题:

XML 文件:

<ref ref-type="sectiona">sdsadsd <email>EffectiveHealthCare@ahrq.hhs.gov</email>sdasd  &commat; Sec asdd</ref>
<ref ref-type="sec">test Sec</ref>
<ref ref-type="sec">seesdasdasd <email>EffectiveHealthCare &commat; dasdasdasd</email>asdad Sec</ref>
<ref ref-type="sec"> Sec</ref>

我的代码:

XmlDocument xmlDocFile = new XmlDocument();
xmlDocFile.Load("xmlfile");

异常

对未声明实体“commat”的引用。第 35 行,位置 65

【问题讨论】:

    标签: c# xml


    【解决方案1】:

    使用这个 xml 节点

    <ref ref-type="sectiona"><![CDATA[sdsadsd <email>EffectiveHealthCare@ahrq.hhs.gov</email>sdasd  &commat; Sec asdd]]></ref>
    <ref ref-type="sec">test Sec</ref>
    <ref ref-type="sec"> Sec</ref>
    <ref ref-type="sec"><![CDATA[seesdasdasd <email>EffectiveHealthCare &commat; dasdasdasd</email>asdad Sec]]></ref>
    

    包含无效值的节点必须转义&lt;![CDATA[....]]&gt;

    【讨论】:

    • 不使用
    • 嗨,你能告诉我如何动态更新 xml 文件中的 CDATA 以及当我们找到“&commat;”时在xml节点中使用c#
    猜你喜欢
    • 2019-04-06
    • 2010-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-17
    • 1970-01-01
    相关资源
    最近更新 更多