XDocumentType コンストラクター

定義

XDocumentType クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
XDocumentType(XDocumentType)

別のXDocumentType オブジェクトからXDocumentType クラスのインスタンスを初期化します。

XDocumentType(String, String, String, String)

XDocumentType クラスのインスタンスを初期化します。

XDocumentType(XDocumentType)

ソース:
XDocumentType.cs
ソース:
XDocumentType.cs
ソース:
XDocumentType.cs
ソース:
XDocumentType.cs
ソース:
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)

ソース:
XDocumentType.cs
ソース:
XDocumentType.cs
ソース:
XDocumentType.cs
ソース:
XDocumentType.cs
ソース:
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

XML ドキュメントのルート要素の修飾名と同じ DTD の修飾名を含む String

publicId
String

外部パブリック DTD のパブリック識別子を含む String

systemId
String

外部プライベート DTD のシステム識別子を含む String

internalSubset
String

内部 DTD の内部サブセットを含む String

次の例では、内部 DTD を使用してドキュメントを作成します。 XDocumentType オブジェクトを作成するときに、DTD (Pubs) の修飾名と、内部サブセットを含む文字列を指定します。 ドキュメントはパブリックまたはプライベートの外部 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.-->

こちらもご覧ください

適用対象