System.Xml.XmlDocument.CreateDocumentType Method

Returns a new System.Xml.XmlDocumentType object.

Syntax

public virtual XmlDocumentType CreateDocumentType (string name, string publicId, string systemId, string internalSubset)

Parameters

name
Name of the document type.
publicId
The public identifier of the document type or null. You can specify a public URI and also a system identifier to identify the location of the external DTD subset.
systemId
The system identifier of the document type or null. Specifies the URL of the file location for the external DTD subset.
internalSubset
The DTD internal subset of the document type or null.

Returns

The new XmlDocumentType.

Remarks

The returned node will have parsed XmlDocumentType.Entities and XmlDocumentType.Notations collections.

Although this method creates the new object in the context of the document, it does not automatically add the new object to the document tree. To add the new object, you must explicitly call one of the node insert methods.

According to the W3C Extensible Markup Language (XML) 1.0 recommendation (www.w3.org/TR/1998/REC-xml-19980210), DocumentType nodes are only allowed within Document nodes. Each System.Xml.XmlDocument can have only one DocumentType node. The DocumentType node must also be inserted before the root element of the XmlDocument (if the document already has a root element, you cannot add a DocumentType node).

If the passed parameters do not combine to build a valid XmlDocumentType, an exception is thrown.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0