<html>
<body>
<p id="demo"></p>
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET.html", "books.xml", true);
xhttp.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
var x = get_lastChild(xmlDoc.getElementsByTagName("book")[0]);
document.getElementById("demo").innerHTML =
x.nodeName;
}
function get_lastChild(n) {
var y = n.lastChild;
while (y.nodeType!=1) {
y = y.previousSibling;
}
return y;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/xml/tryit.asp?filename=try_dom_nav_lastchild by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:56:16 GMT -->
</html>