XmlDocument.CreateDocumentType(String, String, String, String) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Új XmlDocumentType objektumot ad vissza.
public:
virtual System::Xml::XmlDocumentType ^ CreateDocumentType(System::String ^ name, System::String ^ publicId, System::String ^ systemId, System::String ^ internalSubset);
public virtual System.Xml.XmlDocumentType CreateDocumentType(string name, string? publicId, string? systemId, string? internalSubset);
public virtual System.Xml.XmlDocumentType CreateDocumentType(string name, string publicId, string systemId, string internalSubset);
abstract member CreateDocumentType : string * string * string * string -> System.Xml.XmlDocumentType
override this.CreateDocumentType : string * string * string * string -> System.Xml.XmlDocumentType
Public Overridable Function CreateDocumentType (name As String, publicId As String, systemId As String, internalSubset As String) As XmlDocumentType
Paraméterek
- name
- String
A dokumentumtípus neve.
- publicId
- String
A dokumentumtípus vagy nulla . Megadhat egy nyilvános URI-t és egy rendszerazonosítót is a külső DTD-részhalmaz helyének azonosításához.
- systemId
- String
A dokumentumtípus vagy nulla . Megadja a külső DTD-részhalmaz fájlhelyének URL-címét.
- internalSubset
- String
A dokumentumtípus vagy nulla dokumentumtípus belső DTD-részhalmaza.
Válaszok
Az új XmlDocumentType.
Példák
Az alábbi példa létrehoz egy DocumentType-csomópontot, és hozzáadja egy XML-dokumentumhoz.
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);
}
}
Option Explicit
Option Strict
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
End Class
Megjegyzések
A visszaadott Entities csomópont elemzése és Notations gyűjteményei lesznek.
Bár ez a metódus a dokumentum kontextusában hozza létre az új objektumot, nem adja hozzá automatikusan az új objektumot a dokumentumfához. Az új objektum hozzáadásához explicit módon meg kell hívnia a csomópont beszúrási módszereinek egyikét.
A W3C Bővíthető korrektúranyelv (XML) 1.0-s ajánlása szerint a DocumentType csomópontok csak a dokumentumcsomópontokon belül engedélyezettek. Mindegyiknek XmlDocument csak egy DocumentType-csomópontja lehet. A DocumentType csomópontot a gyökérelem XmlDocument elé is be kell szúrni (ha a dokumentumnak már van gyökéreleme, nem vehet fel DocumentType-csomópontot).
Ha az átadott paraméterek nem egyesíthetők érvényes XmlDocumentTypebuildeléshez, kivétel történik.
Megjegyzések az öröklőkhöz
Ez a metódus öröklési igényű. A metódus felülbírálásához CreateDocumentType teljes megbízhatóság szükséges.
Ez a metódus a Dokumentumobjektum-modell (DOM) Microsoft bővítménye.