Propriété de type de document XML DOM
❮ Objet Document
Exemple
Le fragment de code suivant charge " note_internal_dtd.xml " dans xmlDoc et renvoie un objet DocumentType :
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;
}
Sortir:
[object DocumentType]
Définition et utilisation
La propriété doctype renvoie la déclaration de type de document associée au document.
Pour les documents XML sans DTD, cela renvoie null.
Cela fournit un accès direct à l' objet DocumentType (un nœud enfant de ce document).
Syntaxe
documentObject.doctype
❮ Objet Document