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() วิธีการส่งกลับ URI เนมสเปซที่เกี่ยวข้องกับคำนำหน้าที่กำหนด
รองรับเบราว์เซอร์
วิธี lookupNamespaceURI() ได้รับการสนับสนุนในเบราว์เซอร์หลักทั้งหมด
หมายเหตุ: Internet Explorer 9 และรุ่นก่อนหน้าไม่รองรับวิธีนี้
ไวยากรณ์
nodeObject.lookupNamespaceURI(prefix)
พารามิเตอร์
Parameter | Type | Description |
---|---|---|
prefix | String | Required. Specifies the prefix to look for |
คืนมูลค่า
Type | Description |
---|---|
String | The namespace URI associated with the specified prefix |
รายละเอียดทางเทคนิค
เวอร์ชัน DOM | วัตถุโหนดระดับ 3 หลัก |
---|
❮ วัตถุโหนด