function GetXmlHttpObject()
{
xmlHttp=null;
try{
xmlHttp = new XMLHttpRequest(); //Firefox,Opera,Safari浏览器
}
catch(){
try{
xmlHttp = new ActiveObject("Msxm12.XMLHTTP") //IE6.0+浏览器
}
catch()
{
try{
xmlHttp=new ActiveObject("Microsoft.XMIHTTP") //IE6.0-
}
catch(){
alert("对不起,您的浏览器不支持AJAX");
return false;
}
}
}
return xmlHttp;
}
//状态改变
function state_Changed()
{
if(xmlHttp.readyState!=4) return;
if(xmlHttp.status!=200)
{
alert("加载XML文件失败");
return;
}
txt="
x=xmlHttp.responseXML.documentElement.getElementsByTagName("member");
for(i=0;i
{
txt=txt+"
";xx=x[i].getElementsByTagName('name'); //传回名称为name的元素集合
{
try
{
txt=txt+"
"+xx[0].firstChild.nodeValue+"";}
catch
{
txt=txt+"
";}
txt=txt+"
";}
}
txt=txt+"
";document.getElementById("name").innerHTML=txt;
}
function showXML(url)
{
xmlHTTP=GetXmlHttpObject();
if(xmlHTTP!=null)
{
xmlHTTP.onreadystatechange=state_Changed();
xmlHTTP.open("GET",url,true);
xmlHTTP.send(null);
}
}