Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中根据DTD验证XML时出现问题#_C#_Asp.net_Xml_Dtd - Fatal编程技术网

C# 在C中根据DTD验证XML时出现问题#

C# 在C中根据DTD验证XML时出现问题#,c#,asp.net,xml,dtd,C#,Asp.net,Xml,Dtd,这已经困扰我好几天了。我试图将上传文件中的XML加载到XmlDocument对象中,并获得以下死亡黄屏: 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.

这已经困扰我好几天了。我试图将上传文件中的XML加载到XmlDocument对象中,并获得以下死亡黄屏:

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.
这是我的密码。你可以清楚地看到我将prohibidtd设置为false

public static XmlDocument LoadXml(FileUpload fu)
{
    var settings = new XmlReaderSettings
                       {
                           ProhibitDtd = false, 
                           ValidationType = ValidationType.DTD
                       };
    var sDtdPath = string.Format(@"{0}", HttpContext.Current.Server.MapPath("/includes/dtds/2.3/archivearticle.dtd"));
    settings.Schemas.Add(null, sDtdPath);

    var r = XmlReader.Create(new StreamReader(fu.PostedFile.InputStream), settings);
    var document = new XmlDocument();
    document.Load(r);
    return document;
}

XmlResolver=null
添加到
XmlReaderSettings
中。这将阻止xmlDocument尝试访问DTD。如果需要验证,请在单独的操作中进行验证