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