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