Proprietà doctype DOM XML
❮ Oggetto documento
Esempio
Il seguente frammento di codice carica " note_internal_dtd.xml " in xmlDoc e restituisce un oggetto 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;
}
Produzione:
[object DocumentType]
Definizione e utilizzo
La proprietà doctype restituisce la Dichiarazione del tipo di documento associata al documento.
Per i documenti XML senza DTD restituisce null.
Ciò fornisce l'accesso diretto all'oggetto DocumentType (un nodo figlio di questo documento).
Sintassi
documentObject.doctype
❮ Oggetto documento