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