Propiedad XML DOM nodeValue
❮ Objeto de documento
Ejemplo
El siguiente fragmento de código carga " books.xml " en xmlDoc y muestra el nombre del nodo y el valor del nodo raíz:
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;
document.getElementById("demo").innerHTML =
"Nodename: " +
xmlDoc.nodeName +
(" (value: " + xmlDoc.childNodes[0].nodeValue) +
")";
}
La salida del código anterior será:
Nodename: #document (value: null)
Definición y uso
La propiedad nodeValue establece o devuelve el valor de un nodo, según su tipo.
Sintaxis
documentObject.nodeValue
❮ Objeto de documento