XDocumentType 생성자

정의

XDocumentType 클래스의 새 인스턴스를 초기화합니다.

오버로드

Name Description
XDocumentType(XDocumentType)

다른 XDocumentType 개체에서 클래스의 인스턴스를 XDocumentType 초기화합니다.

XDocumentType(String, String, String, String)

클래스의 인스턴스를 초기화합니다 XDocumentType .

XDocumentType(XDocumentType)

Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs

다른 XDocumentType 개체에서 클래스의 인스턴스를 XDocumentType 초기화합니다.

public:
 XDocumentType(System::Xml::Linq::XDocumentType ^ other);
public XDocumentType(System.Xml.Linq.XDocumentType other);
new System.Xml.Linq.XDocumentType : System.Xml.Linq.XDocumentType -> System.Xml.Linq.XDocumentType
Public Sub New (other As XDocumentType)

매개 변수

other
XDocumentType

XDocumentType 복사할 개체입니다.

설명

이 생성자는 XML 트리의 전체 복사본을 만들 때 주로 내부적으로 사용됩니다.

추가 정보

적용 대상

XDocumentType(String, String, String, String)

Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs
Source:
XDocumentType.cs

클래스의 인스턴스를 초기화합니다 XDocumentType .

public:
 XDocumentType(System::String ^ name, System::String ^ publicId, System::String ^ systemId, System::String ^ internalSubset);
public XDocumentType(string name, string publicId, string systemId, string internalSubset);
public XDocumentType(string name, string? publicId, string? systemId, string? internalSubset);
public XDocumentType(string name, string? publicId, string? systemId, string internalSubset);
new System.Xml.Linq.XDocumentType : string * string * string * string -> System.Xml.Linq.XDocumentType
Public Sub New (name As String, publicId As String, systemId As String, internalSubset As String)

매개 변수

name
String

String XML 문서의 루트 요소의 정규화된 이름과 동일한 DTD의 정규화된 이름을 포함하는 A입니다.

publicId
String

String 외부 공용 DTD의 공용 식별자를 포함하는 A입니다.

systemId
String

외부 프라이빗 DTD의 시스템 식별자를 포함하는 A String 입니다.

internalSubset
String

내부 String DTD에 대한 내부 하위 집합을 포함하는 A입니다.

예제

다음 예제에서는 내부 DTD를 사용하여 문서를 만듭니다. 개체를 XDocumentType 만들 때 DTD(Pubs)의 정규화된 이름과 내부 하위 집합이 포함된 문자열을 지정합니다. 문서에서는 공용 또는 프라이빗 외부 DTD를 사용하지 않으므로 이 DTD publicIdsystemIdnull설정됩니다.

string internalSubset = @"<!ELEMENT Pubs (Book+)>
<!ELEMENT Book (Title, Author)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Author (#PCDATA)>";

string target = "xml-stylesheet";
string data = "href=\"mystyle.css\" title=\"Compact\" type=\"text/css\"";

XDocument doc = new XDocument(
    new XComment("This is a comment."),
    new XProcessingInstruction(target, data),
    new XDocumentType("Pubs", null, null, internalSubset),
    new XElement("Pubs",
        new XElement("Book",
            new XElement("Title", "Artifacts of Roman Civilization"),
            new XElement("Author", "Moreno, Jordao")
        ),
        new XElement("Book",
            new XElement("Title", "Midieval Tools and Implements"),
            new XElement("Author", "Gazit, Inbar")
        )
    ),
    new XComment("This is another comment.")
);
doc.Declaration = new XDeclaration("1.0", "utf-8", "true");

Console.WriteLine(doc);
Dim internalSubset = _
    "<!ELEMENT Pubs (Book+)>" & Environment.NewLine & _
    "<!ELEMENT Book (Title, Author)>" & Environment.NewLine & _
    "<!ELEMENT Title (#PCDATA)>" & Environment.NewLine & _
    "<!ELEMENT Author (#PCDATA)>"

Dim doc As XDocument = _
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <!--This is a comment.-->
    <?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?>
    <Pubs>
        <Book>
            <Title>Artifacts of Roman Civilization</Title>
            <Author>Moreno, Jordao</Author>
        </Book>
        <Book>
            <Title>Midieval Tools and Implements</Title>
            <Author>Gazit, Inbar</Author>
        </Book>
    </Pubs>
    <!--This is another comment.-->

doc.FirstNode.NextNode.AddAfterSelf(new XDocumentType("Pubs", Nothing, Nothing, internalSubset))

Console.WriteLine(doc)

이 예제는 다음과 같은 출력을 생성합니다.

<!--This is a comment.-->
<?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?>
<!DOCTYPE Pubs [<!ELEMENT Pubs (Book+)>
<!ELEMENT Book (Title, Author)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Author (#PCDATA)>]>
<Pubs>
  <Book>
    <Title>Artifacts of Roman Civilization</Title>
    <Author>Moreno, Jordao</Author>
  </Book>
  <Book>
    <Title>Midieval Tools and Implements</Title>
    <Author>Gazit, Inbar</Author>
  </Book>
</Pubs>
<!--This is another comment.-->

추가 정보

적용 대상