XML DOM nodeName property

Document object reference manual

Definition and usage

The nodeName property can return the name of the node based on the node type.

Syntax:

documentObject.nodeName

Example

In all examples, we will use the XML file books.xml, as well as 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: " + xmlDoc.nodeName);
document.write(" (nodetype: " + xmlDoc.nodeType);

Output:

Nodename: #document (nodetype: 9)

Document object reference manual