एक्सएमएल डोम इन्सर्टडेटा () विधि
पाठ वस्तु
उदाहरण
निम्न कोड खंड " 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;
var x =
xmlDoc.getElementsByTagName("title")[0].childNodes[0];
x.insertData(0,"Cooking: ");
document.getElementById("demo").innerHTML
=
x.data;
}
आउटपुट:
Cooking: Everyday Italian
परिभाषा और उपयोग
इन्सर्टडेटा () विधि टेक्स्ट नोड में डेटा सम्मिलित करती है।
वाक्य - विन्यास
insertData(start,string)
Parameter | Description |
---|---|
start | Required. Specifies where to begin inserting characters. Start value starts at zero |
string | Required. Specifies the string to insert |
पाठ वस्तु