XML DOM doctype 屬性
定義和用法
doctype 屬性可返回與文檔相關(guān)的文檔類型聲明(Document Type Declaration)。
對于沒有 DTD 的 XML 文檔,則返回 null。
此屬性可提供對 DocumentType 對象(Document 的一個子節(jié)點)的直接訪問。
語法:
documentObject.doctype
實例
在所有的例子中,我們將使用 XML 文件 note_internal_dtd.xml,以及 JavaScript 函數(shù) loadXMLDoc()。
下面的代碼片段可返回一個 DocumentType 對象:
xmlDoc=loadXMLDoc("note_internal_dtd.xml");
document.write(xmlDoc.doctype
);
輸出:
[object DocumentType]