XML DOM lookupNamespaceURI()เมธอด
❮ วัตถุธาตุ
ตัวอย่าง
โค้ดย่อยต่อไปนี้จะโหลด " books_ns.xml " ลงใน xmlDoc และค้นหาเนมสเปซ URI สำหรับคำนำหน้า "c" ที่ระบุ:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books_ns.xml", true);
xhttp.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
var x =
xmlDoc.getElementsByTagName("book")[0];
document.getElementById("demo").innerHTML =
x.lookupNamespaceURI("c");
}
เอาท์พุท:
https://www.w3schools.com/children/
ความหมายและการใช้งาน
lookupNamespaceURI() วิธีการส่งกลับเนมสเปซที่ตรงกับคำนำหน้าที่ระบุบนโหนดปัจจุบัน
ไวยากรณ์
elementNode.lookupNamespaceURI(prefix)
Parameter | Description |
---|---|
prefix | Required. A string that specifies prefix to find |
❮ วัตถุธาตุ