اقتراحات الدورة
XML DOM createComment() Method
تعريف والاستخدام
createComment()
الطريقة التي تخلق نقط تعليق.
هذه الطريقة تعود Comment Object.
النحوبياناتcreateComment(
) | وصف |
---|---|
بيانات | الخط النصي، يحدد بيانات العنصر. |
مثال
هذا الكود سيدخل "books.xml" إلى xmlDoc ويضيف نقاط التعليق إلى عنصر <book>:
هذا، 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، newComment، xmlDoc، txt; xmlDoc = xml.responseXML; txt = ""; x = xmlDoc.getElementsByTagName("book"); للفورك (i = 0; i < x.length; i++) { newComment = xmlDoc.createComment("Revised April 2008"); x[i].appendChild(newComment); {} للفورك (i = 0; i < x.length; i++) { txt += x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue + " - " + x[i].lastChild.nodeValue + "<br>"; {} document.getElementById("demo").innerHTML = txt; {}