XML DOM doctype 屬性
定義和用法
doctype
屬性返回與文檔關聯的文檔類型聲明。
對于沒有 DTD 的 XML 文檔,此屬性返回 null。
這提供了對 DocumentType 對象的直接訪問。
語法
documentObject.doctype
實例
下面的代碼將 "note_internal_dtd.xml" 加載到 xmlDoc 中,并返回 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; }