Propiedad nodeType del DOM XML
Definición y uso
nodeType
La propiedad devuelve el tipo de nodo del nodo.
Sintaxis
nodeObject.nodeType
Ejemplo
El siguiente código cargará "books.xml" en xmlDoc y mostrará el nombre y el tipo 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 + " (nodetype: " + xmlDoc.nodeType + ")"; }