XmlReaderSettings.ProhibitDtd 속성

정의

주의

Use XmlReaderSettings.DtdProcessing property instead.

주의

XmlReaderSettings.ProhibitDtd has been deprecated. Use DtdProcessing instead.

DTD(문서 형식 정의) 프로세스를 금지할지를 나타내는 값을 가져오거나 설정합니다. 이 속성은 사용되지 않습니다. 대신 DtdProcessing를 사용하세요.

public:
 property bool ProhibitDtd { bool get(); void set(bool value); };
[System.Obsolete("Use XmlReaderSettings.DtdProcessing property instead.")]
public bool ProhibitDtd { get; set; }
[System.Obsolete("XmlReaderSettings.ProhibitDtd has been deprecated. Use DtdProcessing instead.")]
public bool ProhibitDtd { get; set; }
public bool ProhibitDtd { get; set; }
[<System.Obsolete("Use XmlReaderSettings.DtdProcessing property instead.")>]
member this.ProhibitDtd : bool with get, set
[<System.Obsolete("XmlReaderSettings.ProhibitDtd has been deprecated. Use DtdProcessing instead.")>]
member this.ProhibitDtd : bool with get, set
member this.ProhibitDtd : bool with get, set
Public Property ProhibitDtd As Boolean

속성 값

Boolean

DTD 프로세스를 금지하면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

특성

예제

다음 예제에서는 DTD를 사용하여 데이터의 유효성을 검사합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::Xml;
using namespace System::Xml::Schema;
using namespace System::IO;

// Display any validation errors.
static void ValidationCallBack( Object^ /*sender*/, ValidationEventArgs^ e )
{
   Console::WriteLine( L"Validation Error: {0}", e->Message );
}

int main()
{
   // Set the validation settings.
   XmlReaderSettings^ settings = gcnew XmlReaderSettings;
   settings->DtdProcessing = DtdProcessing::Parse;
   settings->ValidationType = ValidationType::DTD;
   settings->ValidationEventHandler += gcnew ValidationEventHandler( ValidationCallBack );

   // Create the XmlReader object.
   XmlReader^ reader = XmlReader::Create( L"itemDTD.xml", settings );

   // Parse the file. 
   while ( reader->Read() )
      ;

   return 1;
}
using System;
using System.Xml;
using System.Xml.Schema;
using System.IO;

public class Sample {

  public static void Main() {

    // Set the validation settings.
    XmlReaderSettings settings = new XmlReaderSettings();
    settings.DtdProcessing = DtdProcessing.Parse;
    settings.ValidationType = ValidationType.DTD;
    settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);

    // Create the XmlReader object.
    XmlReader reader = XmlReader.Create("itemDTD.xml", settings);

    // Parse the file.
    while (reader.Read());
  }

  // Display any validation errors.
  private static void ValidationCallBack(object sender, ValidationEventArgs e) {
    Console.WriteLine("Validation Error: {0}", e.Message);
  }
}
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO

public class Sample 

  public shared sub Main() 

    ' Set the validation settings.
    Dim settings as XmlReaderSettings = new XmlReaderSettings()
    settings.DtdProcessing = DtdProcessing.Parse
    settings.ValidationType = ValidationType.DTD
    AddHandler settings.ValidationEventHandler, AddressOf ValidationCallBack
 
    ' Create the XmlReader object.
    Dim reader as XmlReader = XmlReader.Create("itemDTD.xml", settings)

    ' Parse the file. 
    while reader.Read()
    end while
    
  end sub

  ' Display any validation errors.
  private shared sub ValidationCallBack(sender as object, e as ValidationEventArgs) 
    Console.WriteLine("Validation Error: {0}", e.Message)
  end sub
end class

이 예제에서는 itemDTD.xml 파일을 입력으로 사용합니다.

<!--XML file using a DTD-->
<!DOCTYPE store [
  <!ELEMENT store (item)*> 
  <!ELEMENT item (name,dept,price)>
  <!ATTLIST item type CDATA #REQUIRED>
  <!ELEMENT name (#PCDATA)>
  <!ELEMENT price (#PCDATA)>]>
<store>
  <item type="supplies"  ISBN="2-3631-4">
    <name>paint</name>
    <price>16.95</price>
  </item>
</store>

설명

로 설정 trueXmlReader 하면 DTD 콘텐츠가 XmlException 발견되면 throw됩니다. 서비스 거부 문제가 염려되거나 신뢰할 수 없는 소스를 사용하는 경우 DTD 처리를 사용하지 마십시오.

DTD 처리를 활성화하는 경우 XmlSecureResolver를 사용하여 XmlReader가 액세스할 수 있는 리소스를 제한할 수 있습니다. 또한 애플리케이션을 직접 디자인하여 XML 처리에 필요한 메모리 및 시간을 제한할 수 있습니다. 예를 들어, ASP.NET 애플리케이션에서 시간 제한을 구성합니다.

이 속성은 사용되지 않습니다. 대신 DtdProcessing를 사용하세요. 기본값 true DtdProcessing Prohibit으로 설정한 ProhibitDtd 경우 . 로 설정 ProhibitDtd DtdProcessing Parse했다면 .false

적용 대상