Get your own website Result Size: 625 x 565
x
 
<!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.html", "books.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("book")[0]
    var y = x.getAttributeNode("category");
    var txt = y.nodeValue + "<br>";
    y.nodeValue ="food";
    txt += y.nodeValue;
    document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/xml/tryit.asp?filename=try_dom_att_nodevalue by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 14:44:18 GMT -->
</html>