XmlDocument.DocumentType XmlDocument.DocumentType XmlDocument.DocumentType XmlDocument.DocumentType Property

정의

DOCTYPE 선언이 포함된 노드를 가져옵니다.Gets the node containing the DOCTYPE declaration.

public:
 virtual property System::Xml::XmlDocumentType ^ DocumentType { System::Xml::XmlDocumentType ^ get(); };
public virtual System.Xml.XmlDocumentType DocumentType { get; }
member this.DocumentType : System.Xml.XmlDocumentType
Public Overridable ReadOnly Property DocumentType As XmlDocumentType

속성 값

DocumentType(DOCTYPE 선언)이 포함된 XmlNode입니다.The XmlNode containing the DocumentType (DOCTYPE declaration).

예제

다음 예제에서는 가져오고 문서의 DOCTYPE 선언을 표시 합니다.The following example gets and displays the DOCTYPE declaration for the document.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create the XmlDocument.
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<!DOCTYPE book [<!ENTITY h 'hardcover'>]>"
   "<book genre='novel' ISBN='1-861001-57-5'>"
   "<title>Pride And Prejudice</title>"
   "<style>&h;</style>"
   "</book>" );
   
   // Display the DocumentType.
   Console::WriteLine( doc->DocumentType->OuterXml );
}

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
    // Create the XmlDocument.
    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<!DOCTYPE book [<!ENTITY h 'hardcover'>]>" +
                "<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "<style>&h;</style>" +
                "</book>");

    // Display the DocumentType.
    Console.WriteLine(doc.DocumentType.OuterXml);

  }
}
Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    Public Shared Sub Main()
        ' Create the XmlDocument.
        Dim doc As New XmlDocument()
        doc.LoadXml("<!DOCTYPE book [<!ENTITY h 'hardcover'>]>" & _
                    "<book genre='novel' ISBN='1-861001-57-5'>" & _
                    "<title>Pride And Prejudice</title>" & _
                    "<style>&h;</style>" & _
                    "</book>")
        
        ' Display the DocumentType.
        Console.WriteLine(doc.DocumentType.OuterXml)
    End Sub 'Main 
End Class 'Sample

설명

XmlDocument 하나의 자식으로 가질 수 있습니다 XmlNodeType DocumentType 같음.An XmlDocument can have one and only one child with XmlNodeType equal to DocumentType.

참고

이 속성은 읽기 전용입니다.This property is read-only. DocumentType 노드를 변경 하려면 기존 노드를 삭제를 사용 하 여 새 하나 만듭니다는 CreateDocumentType 메서드를 문서에 새 노드를 추가 합니다.To change the DocumentType node, delete the existing node, create a new one using the CreateDocumentType method, and add the new node to the document.

적용 대상

추가 정보