<!DOCTYPE html>
<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", "books_ns.xml", true);
xhttp.send();
function myFunction(xml) {
var xmlDoc = xml.responseXML;
var x = xmlDoc.getElementsByTagName("title")[0];
var ns = "https://www.w3schools.com/children/";
var y = x.getAttributeNodeNS(ns,"lang");
document.getElementById("demo").innerHTML =
y.nodeName + " = " + y.nodeValue;
}
</script>
</body>
</html>