<html>
<head>
<script type="text/javascript">
var xmlhttp;
function loadxmldoc(url)
{
xmlhttp=null;
if (window.xmlhttprequest)
{// code for ie7, firefox, mozilla, etc.
xmlhttp=new xmlhttprequest();
}
else if (window.activexobject)
{// code for ie5, ie6
xmlhttp=new activexobject("microsoft.xmlhttp");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=onresponse;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
}
else
{
alert("your browser does not support xmlhttp.");
}
}
function onresponse()
{
if(xmlhttp.readystate!=4) return;
if(xmlhttp.status!=200)
{
alert("problem retrieving xml data");
return;
}
txt="<table border='1'>";
x=xmlhttp.responsexml.documentelement.getelementsbytagname("cd");
for (i=0;i<x.length;i++)
{
txt=txt + "<tr>";
xx=x[i].getelementsbytagname("title");
{
try
{
txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>";
}
catch (er)
{
txt=txt + "<td> </td>";
}
}
xx=x[i].getelementsbytagname("artist");
{
try
{
txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>";
}
catch (er)
{
txt=txt + "<td> </td>";
}
}
txt=txt + "</tr>";
}
txt=txt + "</table>";
document.getelementbyid('copy').innerhtml=txt;
}
</script>
</head>
<body>
<div id="copy">
<button onclick="loadxmldoc('/example/xmle/cd_catalog.xml')">get cd info</button>
</div>
</body>
</html>
新闻热点
疑难解答
图片精选