XML DOM nodeType attribute

Node object reference manual

Definition and usage

The nodeType attribute can return the node type of the node.

Syntax:

nodeObject.nodeType

Example

In all examples, we will use the XML file books.xml, and the 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)

Node object reference manual