XML DOM 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;
}
輸出
Document location: https://w3schools.tw/xml/books.xml
自己動手試一試 »
定義和用法
documentURI 屬性設定或返回文件的位置。
語法
documentObject.documentURI
❮ 文件物件