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 เนมสเปซที่ระบุบนโหนดปัจจุบัน
ไวยากรณ์
elementNode.lookupPrefix(URI)
Parameter | Description |
---|---|
URI | Required. The namespace URI for the prefix to find |
❮ วัตถุธาตุ