源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <script> if (window.XMLHttpRequest) { // IE7+, Firefox, Chrome, Opera, Safari 瀏覽器執行代碼 xhttp=new XMLHttpRequest(); } else { // IE6, IE5 瀏覽器執行代碼 xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET","books.xml",false); xhttp.send(); xmlDoc=xhttp.responseXML; document.write("XML 文檔載入到 XML DOM 對象。"); </script> </body> </html>
運行結果