XML DOM property nodeValue
التعريف والاستخدام
nodeValue
إعداد أو إرجاع قيمة العنصر، بناءً على نوعه.
القواعد
attrObject.nodeValue
مثال
أيما من التالي يلزم "books.xml" يتم تحميله إلى xmlDoc ويظهر اسم العنصر والقيمة والنوع:
تعريف xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = وظيفة() { إذا (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "books.xml", true); xhttp.send(); وظيفة myFunction(xml) { تعريف x, i, xmlDoc, txt; xmlDoc = xml.responseXML; txt = ""; x = xmlDoc.getElementsByTagName('book'); للمسلسل = 0; للمسلسل < x.length; للمسلسل++) { txt += x.item(i).attributes[0].nodeName + " = " + x.item(i).attributes[0].nodeValue + " (nodetype: " + x.item(i).attributes[0].nodeType + ")" + "<br>"; } document.getElementById("demo").innerHTML = txt; }