<!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", "/demo/xml/books.xml", true);xhttp.send();
function myFunction(xml) { var x, newComment, xmlDoc;
xmlDoc = xml.responseXML;
newComment = xmlDoc.createComment("2024 年 2 月修订"); x = xmlDoc.getElementsByTagName("book")[0]; x.appendChild(newComment);
document.getElementById("demo").innerHTML = x.lastChild.nodeValue;}
</script>
</body>
</html>