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; }