<small id='v2KjH'></small><noframes id='v2KjH'>

  1. <tfoot id='v2KjH'></tfoot>
  2. <legend id='v2KjH'><style id='v2KjH'><dir id='v2KjH'><q id='v2KjH'></q></dir></style></legend>

    <i id='v2KjH'><tr id='v2KjH'><dt id='v2KjH'><q id='v2KjH'><span id='v2KjH'><b id='v2KjH'><form id='v2KjH'><ins id='v2KjH'></ins><ul id='v2KjH'></ul><sub id='v2KjH'></sub></form><legend id='v2KjH'></legend><bdo id='v2KjH'><pre id='v2KjH'><center id='v2KjH'></center></pre></bdo></b><th id='v2KjH'></th></span></q></dt></tr></i><div id='v2KjH'><tfoot id='v2KjH'></tfoot><dl id='v2KjH'><fieldset id='v2KjH'></fieldset></dl></div>

      • <bdo id='v2KjH'></bdo><ul id='v2KjH'></ul>

      xml 文档异常中禁止的 DTD

      时间:2023-08-28
        <tfoot id='TKoaX'></tfoot>
          <tbody id='TKoaX'></tbody>
        • <legend id='TKoaX'><style id='TKoaX'><dir id='TKoaX'><q id='TKoaX'></q></dir></style></legend>
          <i id='TKoaX'><tr id='TKoaX'><dt id='TKoaX'><q id='TKoaX'><span id='TKoaX'><b id='TKoaX'><form id='TKoaX'><ins id='TKoaX'></ins><ul id='TKoaX'></ul><sub id='TKoaX'></sub></form><legend id='TKoaX'></legend><bdo id='TKoaX'><pre id='TKoaX'><center id='TKoaX'></center></pre></bdo></b><th id='TKoaX'></th></span></q></dt></tr></i><div id='TKoaX'><tfoot id='TKoaX'></tfoot><dl id='TKoaX'><fieldset id='TKoaX'></fieldset></dl></div>
          1. <small id='TKoaX'></small><noframes id='TKoaX'>

              <bdo id='TKoaX'></bdo><ul id='TKoaX'></ul>
              1. 本文介绍了xml 文档异常中禁止的 DTD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                尝试在 C# 应用程序中解析 XML 文档时遇到此错误:

                I'm getting this error when trying to parse through an XML document in a C# application:

                出于安全原因,此 XML 文档中禁止使用 DTD.要启用 DTD 处理,请将 XmlReaderSettings 上的 ProhibitDtd 属性设置为 false,并将设置传递给 XmlReader.Create 方法."

                "For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method."

                作为参考,异常发生在以下代码的第二行:

                For reference, the exception occurred at the second line of the following code:

                using (XmlReader reader = XmlReader.Create(uri))
                {
                    reader.MoveToContent(); //here
                
                    while (reader.Read()) //(code to parse xml doc follows).
                

                我对 Xml 的了解非常有限,我不知道 DTD 处理是什么,也不知道如何执行错误消息提示的操作.关于可能导致此问题的原因以及如何解决此问题的任何帮助?谢谢...

                My knowledge of Xml is pretty limited and I have no idea what DTD processing is nor how to do what the error message suggests. Any help as to what may be causing this and how to fix it? thanks...

                推荐答案

                请注意,settings.ProhibitDtd 现在已经过时,请改用 DtdProcessing:(Ignore、Parse 或 Prohibit 的新选项)

                Note that settings.ProhibitDtd is now obsolete, use DtdProcessing instead: (new options of Ignore, Parse, or Prohibit)

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.DtdProcessing = DtdProcessing.Parse;
                

                如本文所述:十亿笑 XML DoS 攻击如何工作?

                您应该限制字符数以避免 DoS 攻击:

                you should add a limit to the number of characters to avoid DoS attacks:

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.DtdProcessing = DtdProcessing.Parse;
                settings.MaxCharactersFromEntities = 1024;
                

                这篇关于xml 文档异常中禁止的 DTD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何用 C# 编写解析器? 下一篇:如何使用 C#/LINQ 将 XML 转换为 JSON?

                相关文章

                最新文章

              2. <tfoot id='WTsbD'></tfoot>

                  • <bdo id='WTsbD'></bdo><ul id='WTsbD'></ul>

                  <small id='WTsbD'></small><noframes id='WTsbD'>

                  1. <legend id='WTsbD'><style id='WTsbD'><dir id='WTsbD'><q id='WTsbD'></q></dir></style></legend>
                  2. <i id='WTsbD'><tr id='WTsbD'><dt id='WTsbD'><q id='WTsbD'><span id='WTsbD'><b id='WTsbD'><form id='WTsbD'><ins id='WTsbD'></ins><ul id='WTsbD'></ul><sub id='WTsbD'></sub></form><legend id='WTsbD'></legend><bdo id='WTsbD'><pre id='WTsbD'><center id='WTsbD'></center></pre></bdo></b><th id='WTsbD'></th></span></q></dt></tr></i><div id='WTsbD'><tfoot id='WTsbD'></tfoot><dl id='WTsbD'><fieldset id='WTsbD'></fieldset></dl></div>