XML DOM documentURI 属性
定义和用法
documentURI
属性设置或返回文档的位置。
语法
documentObject.documentURI
实例
下面的代码将 "books.xml" 加载到 xmlDoc 中,并显示 XML 文档的位置:
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; document.getElementById("demo").innerHTML = "Document location: " + xmlDoc.documentURI; }