XmlDocument.CreateDocumentType メソッド
アセンブリ: System.Xml (system.xml.dll 内)

Public Overridable Function CreateDocumentType ( _ name As String, _ publicId As String, _ systemId As String, _ internalSubset As String _ ) As XmlDocumentType
Dim instance As XmlDocument Dim name As String Dim publicId As String Dim systemId As String Dim internalSubset As String Dim returnValue As XmlDocumentType returnValue = instance.CreateDocumentType(name, publicId, systemId, internalSubset)
public virtual XmlDocumentType CreateDocumentType ( string name, string publicId, string systemId, string internalSubset )
public: virtual XmlDocumentType^ CreateDocumentType ( String^ name, String^ publicId, String^ systemId, String^ internalSubset )
public XmlDocumentType CreateDocumentType ( String name, String publicId, String systemId, String internalSubset )
public function CreateDocumentType ( name : String, publicId : String, systemId : String, internalSubset : String ) : XmlDocumentType
- publicId
ドキュメントの種類のパブリック ID。null 参照 (Visual Basic では Nothing)。パブリック URI およびシステム ID を指定して、外部 DTD サブセットの場所を特定できます。
新しい XmlDocumentType。

返されたノードには、解析済みの Entities コレクションおよび Notations コレクションがあります。
このメソッドは、ドキュメントのコンテキスト内で新しいオブジェクトを作成しますが、自動的には新しいオブジェクトをドキュメント ツリーに追加しません。新しいオブジェクトを追加するには、ノード挿入メソッドのいずれか 1 つを明示的に呼び出す必要があります。
W3C 勧告『Extensible Markup Language (XML) 1.0』(www.w3.org/TR/1998/REC-xml-19980210) に従って、DocumentType ノードは Document ノード内だけで使用できます。それぞれの XmlDocument は、DocumentType ノードを 1 つだけ持つことができます。DocumentType ノードも XmlDocument のルート要素より前に挿入する必要があります。つまり、ドキュメントに既にルート要素がある場合は、DocumentType ノードを追加できません。
渡されたパラメータを組み合わせても有効な XmlDocumentType が作成されない場合は、例外がスローされます。
継承時の注意 このメソッドには継承確認要求があります。CreateDocumentType メソッドをオーバーライドするには、完全な信頼が必要です。詳細については、「継承確認要求」を参照してください。 このメソッドは、DOM (Document Object Model) に対する Microsoft 拡張機能です。
DocumentType ノードを作成し、XML ドキュメントに追加する例を次に示します。
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() 'Create a document type node and 'add it to the document. Dim doctype As XmlDocumentType doctype = doc.CreateDocumentType("book", Nothing, Nothing, "<!ELEMENT book ANY>") doc.AppendChild(doctype) 'Create the root element and 'add it to the document. doc.AppendChild(doc.CreateElement("book")) Console.WriteLine("Display the modified XML...") doc.Save(Console.Out) End Sub 'Main End Class 'Sample
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { //Create the XmlDocument. XmlDocument doc = new XmlDocument(); //Create a document type node and //add it to the document. XmlDocumentType doctype; doctype = doc.CreateDocumentType("book", null, null, "<!ELEMENT book ANY>"); doc.AppendChild(doctype); //Create the root element and //add it to the document. doc.AppendChild(doc.CreateElement("book")); Console.WriteLine("Display the modified XML..."); doc.Save(Console.Out); } }
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { //Create the XmlDocument. XmlDocument^ doc = gcnew XmlDocument; //Create a document type node and //add it to the document. XmlDocumentType^ doctype; doctype = doc->CreateDocumentType( "book", nullptr, nullptr, "<!ELEMENT book ANY>" ); doc->AppendChild( doctype ); //Create the root element and //add it to the document. doc->AppendChild( doc->CreateElement( "book" ) ); Console::WriteLine( "Display the modified XML..." ); doc->Save( Console::Out ); }
import System.*; import System.IO.*; import System.Xml.*; public class Sample { public static void main(String[] args) { //Create the XmlDocument. XmlDocument doc = new XmlDocument(); //Create a document type node and //add it to the document. XmlDocumentType doctype; doctype = doc.CreateDocumentType("book", null, null, "<!ELEMENT book ANY>"); doc.AppendChild(doctype); //Create the root element and //add it to the document. doc.AppendChild(doc.CreateElement("book")); Console.WriteLine("Display the modified XML..."); doc.Save(Console.get_Out()); } //main } //Sample

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlDocument.CreateDocumentType メソッドを検索する場合は、下記のリンクをクリックしてください。

- XmlDocument.CreateDocumentType メソッドのページへのリンク