Name

doctype: DocumentType

Synopsis

This attribute returns an instance of the DocumentType interface representing the document type declaration for this document. If no DOCTYPE declaration was in the document, this property is null. Prior to DOM Level 3, the DocumentType node associated with a document was immutable and could not be created directly. In Level 3 implementations, the doctype attribute is a shortcut to the DocumentType node that is currently linked into the document node hierarchy. Read-only.

Java binding

public DocumentType getDoctype( );

Java example

// Get the parsed DTD information for this document
DocumentType docType = docIn.getDoctype( );
     
if (docType =  = null) {
    System.out.println("warning: no DTD provided");
}

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.