THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

XML DOM documentElement Property


Document Object Reference Document Object

Example

The following code fragment loads "books.xml" into xmlDoc and displays the location of the XML document:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
��� if (xhttp.readyState == 4 && xhttp.status == 200) {
������� myFunction(xhttp);
��� }
};
xhttp.open("GET", "books.xml", true);
xhttp.send();

function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.documentElement;
    document.getElementById("demo").innerHTML =
    "Nodename: " + x.nodeName + "<br>" +
    "Nodevalue: " + x.nodeValue + "<br>" +
    "Nodetype: " + x.nodeType;
}

Output:

Nodename: bookstore
Nodevalue: null
Nodetype: 1
Try it yourself »

Definition and Usage

The documentElement property returns the root node of the document.

Syntax

documentObject.documentElement

Document Object Reference Document Object