Uhusiano wa XML DOM data
Mifano na matumizi
data
Mimewa au kirejeza ujumbe wa mabano.
Muundo
commentNode.data
Mfano
Hii ni kodi ambalo huzingatia "books_comment.xml" kwenye xmlDoc na kichapisha ujumbe wa kina <book>:
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "books_comment.xml", true); xhttp.send(); function myFunction(xml) { var x, i, xmlDoc, txt; xmlDoc = xml.responseXML; txt = ""; x = xmlDoc.getElementsByTagName("book")[0].childNodes; kwa (i = 0; i < x.length; i++) { if (x[i].nodeType == 8) { txt += x[i].data + "<br>"; } } document.getElementById("demo").innerHTML = txt; }
Kwenye mafano wa juu, tumekuwa tukichukua mazingira na ifuatilia ifikio, kuzingatia kwamba tumekuwa tukipenda kusaidia mafanikio. Aina ya mafanikio wa mafanikio ni 8.