<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 x, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName('book');
// Set textContent
for(i = 0; i < x.length; i++) {
x.item(i).textContent = "Outdated";
}
// Output textContent
for(i = 0; i < x.length; i++) {
txt += x.item(i).textContent + "<br>";
}
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/xml/tryit.asp?filename=try_dom_node_textcontent_set by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:16:54 GMT -->
</html>