XML DOM doctype Eigenschap
❮ Documentobject
Voorbeeld
Het volgende codefragment laadt " note_internal_dtd.xml " in xmlDoc en retourneert een 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;
}
Uitgang:
[object DocumentType]
Definitie en gebruik
De eigenschap doctype retourneert de Document Type Declaration die aan het document is gekoppeld.
Voor XML-documenten zonder DTD geeft dit null terug.
Dit biedt directe toegang tot het DocumentType-object (een onderliggende node van dit document).
Syntaxis
documentObject.doctype
❮ Documentobject