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