Méthode appendData() du DOM XML
Définition et utilisation
appendData()
La méthode ajoute des données à la fin du nœud CDATA.
Syntaxe
CDATANode.appendData(string)
Paramètre | Description |
---|---|
string | Obligatoire. La chaîne de caractères à ajouter au nœud CDATA. |
Exemple
Le code suivant charge "books_cdata.xml" dans xmlDoc et ajoute le texte à l'élément <html> premier :
var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { myFunction(this); } }; xhttp.open("GET", "books_cdata.xml", true); xhttp.send(); function myFunction(xml) { var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName("html")[0].childNodes[0]; x.appendData(" Wonderful!"); document.getElementById("demo").innerHTML = x.data; }