XML DOM ownerDocument 屬性
定義和用法
ownerDocument
屬性返回所選元素所屬的文檔對象。
語法
elementNode.ownerDocument
實例
下面的代碼將 "books.xml" 加載到 xmlDoc 中,并從第一個 <title> 元素的所有者文檔中獲取名稱和節點類型:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "books.xml", true); xhttp.send(); function myFunction(xml) { var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName("title")[0].ownerDocument; document.getElementById("demo").innerHTML = "Nodename: " + x.nodeName + " (nodetype: " + x.nodeType + ")" }