XML DOM doctype attribute

Definition and Usage

doctype This property returns the document type declaration associated with the document.

For XML documents without a DTD, this property returns null.

This provides direct access to the DocumentType object.

Syntax

documentObject.doctype

Instance

The following code loads "note_internal_dtd.xml" into xmlDoc and returns the DocumentType object:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   {}
};
xhttp.open("GET", "note_internal_dtd.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    document.getElementById("demo").innerHTML =
    xmlDoc.doctype;
{}

Try It Yourself