XmlDocument.CreateDocumentType メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlDocument.CreateDocumentType メソッドの意味・解説 

XmlDocument.CreateDocumentType メソッド

新しい XmlDocumentType オブジェクト返します

名前空間: System.Xml
アセンブリ: 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

パラメータ

name

ドキュメント種類の名前。

publicId

ドキュメント種類パブリック IDnull 参照 (Visual Basic では Nothing)。パブリック URI およびシステム ID指定して外部 DTD サブセットの場所を特定できます

systemId

ドキュメント種類システム ID。または null 参照 (Visual Basic では Nothing)。外部 DTD サブセットファイル位置URL指定します

internalSubset

ドキュメント種類DTD 内部サブセット。または null 参照 (Visual Basic では Nothing)。

戻り値
新し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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からXmlDocument.CreateDocumentType メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からXmlDocument.CreateDocumentType メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からXmlDocument.CreateDocumentType メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「XmlDocument.CreateDocumentType メソッド」の関連用語

XmlDocument.CreateDocumentType メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlDocument.CreateDocumentType メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS