XML DOM documentElement Attribute

Document Object Reference Manual

Definition and Usage

The documentElement attribute can return the root node of the document.

Syntax:

documentObject.documentElement

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 location of the XML document:

xmlDoc=loadXMLDoc("/example/xdom/books.xml");
var x=xmlDoc.documentElement;
document.write("Nodename: " + x.nodeName + "<br />");
document.write("Nodevalue: " + x.nodeValue + "<br />");
document.write("Nodetype: " + x.nodeType);

Output:

Nodename: bookstore
Nodevalue: null
Nodetype: 1

Document Object Reference Manual