XML DOM doctype Property


❮ Document Object

Example

The following code fragment loads "note_internal_dtd.xml" into xmlDoc and returns a 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;
}

Output:

[object DocumentType]
Try it Yourself »

Definition and Usage

The doctype property returns the Document Type Declaration associated with the document.

For XML documents without a DTD this returns null.

This provides direct access to the DocumentType object (a child node of this Document).

Syntax

documentObject.doctype

❮ Document Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.