Método appendData() del XML DOM
Definición y uso
appendData()
El método agrega datos al final del nodo CDATA.
Sintaxis
CDATANode.appendData(string)
Parámetro | Descripción |
---|---|
string | Obligatorio. La cadena de caracteres que se añadirá al nodo CDATA. |
Ejemplo
El siguiente código cargará "books_cdata.xml" en xmlDoc y añadirá el texto al primer elemento <html>:
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(" ¡Maravilloso!"); document.getElementById("demo").innerHTML = x.data; }