XML DOM 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;
}
輸出
[object DocumentType]
自己動手試一試 »
定義和用法
doctype 屬性返回與文件關聯的文件型別宣告。
對於沒有 DTD 的 XML 文件,此屬性返回 null。
這提供了對 DocumentType 物件(此 Document 的子節點)的直接訪問。
語法
documentObject.doctype
❮ 文件物件