XML DOM nodeType attribute
Definition and usage
The nodeType attribute can return the node type of the node.
Syntax:
documentObject.nodeType
Example
In all examples, we will use the XML file books.xml, and JavaScript function loadXMLDoc().
The following code snippet can display the node name and node type of the root node:
xmlDoc=loadXMLDoc("books.xml");
document.write("Nodename: ")
document.write(" (nodetype: ") xmlDoc.nodeType
);
Output:
Nodename: #document (nodetype: 9)