<script type="text/javascript">
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
if (xmlhttp.readyState==4 && xmlhttp.status==200)
xmlDoc=xmlhttp.responseXML;
x=xmlDoc.getElementsByTagName("title");
txt=txt + x[i].childNodes[0].nodeValue + "<br />";
document.getElementById("myDiv").innerHTML=txt;
xmlhttp.open("GET","/example/books.xml",true);
<h2>My Book Collection:</h2>
<button type="button" onclick="loadXMLDoc()">获得我的图书收藏列表</button>