XML DOM nodeValueคุณสมบัติ
❮ วัตถุโหนด
ตัวอย่าง
โค้ดย่อยต่อไปนี้โหลด " books.xml " ลงใน xmlDoc และแสดงชื่อโหนดและค่าโหนดของโหนดรูท:
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 =
"Nodename: " +
xmlDoc.nodeName +
(" (value: " + xmlDoc.childNodes[0].nodeValue) +
")";
}
ผลลัพธ์ของโค้ดด้านบนจะเป็น:
Nodename: #document (value: null)
ความหมายและการใช้งาน
คุณสมบัติ nodeValue ตั้งค่าหรือส่งคืนค่าของโหนด ขึ้นอยู่กับประเภทของโหนด
ไวยากรณ์
nodeObject.nodeValue
❮ วัตถุโหนด