<script language="javascript">
function f1() {
//创建xmlHttp对象
var xmlHttp;
if(window.ActiveXObject)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp=new XMLHttpRequest();
}
var url="/TXML.xml";
var txt,Company,cNname,cIP;
var i;
//提交数据
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4&&xmlHttp.status==200){
txt="<table border='1'><tr><th>cNname</th><th>cIP</th></tr>";
Company=xmlHttp.responseXML.documentElement.getElementsByTagName("Company");
for(i=0;i<Company.length;i++){
txt=txt+"<tr>";
cNname=Company[i].getElementsByTagName("cNname");
{
try
{
txt=txt+"<td>"+cNname[0].firstChild.nodeValue+"</td>";
}
catch(er)
{
txt=txt+"<td></td>";
}
}
cIP=Company[i].getElementsByTagName("cIP");
{
try
{
txt=txt+"<td>"+cIP[0].firstChild.nodeValue+"</td>";
}
catch(er)
{
txt=txt+"<td></td>";
}
}
txt=txt + "</tr>";
}
txt=txt + "</table>";
document.getElementById('d1').innerHTML=txt;
}
}
xmlHttp.open("get",url,true);
xmlHttp.send();
}
</script>
<DongFang> <Company> <cNname>1</cNname> <cIP>1</cIP> </Company> <Company> <cNname>2</cNname> <cIP>2</cIP> </Company> <Company> <cNname>3</cNname> <cIP>3</cIP> </Company> <Company> <cNname>4</cNname> <cIP>4</cIP> </Company> <Company> <cNname>5</cNname> <cIP>5</cIP> </Company> <Company> <cNname>6</cNname> <cIP>6</cIP> </Company></DongFang>
原文链接:https://www.f2er.com/ajax/163344.html