XML DOM xmlStandalone 屬性
❮ 文件物件
示例
以下程式碼片段將 "books.xml" 載入到 xmlDoc 中,並顯示文件的 XML 編碼、standalone 屬性和 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 =
"XML encoding: " + xmlDoc.xmlEncoding +
"<br>XML standalone: " + xmlDoc.xmlStandalone +
"<br>XML version: " + xmlDoc.xmlVersion +
"<br>Encoding used when parsing: " + xmlDoc.inputEncoding;
}
輸出
XML encoding: UTF-8
XML standalone: false
XML version: 1.0
Encoding when parsing: UTF-8
自己動手試一試 »
定義和用法
xmlStandalone 屬性用於設定或返回文件是否為獨立的。
語法
documentObject.xmlStandalone
❮ 文件物件