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