person.htm: 复制代码 代码如下: <BR>var xmlDoc=null; <BR>if (window.ActiveXObject) <BR>{ <BR>// for IE <BR>xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); <BR>} <BR>else if (document.implementation.createDocument) <BR>{ <BR>//for Mozilla, Firefox, Opera, <BR>xmlDoc=document.implementation.createDocument("","",null); <BR>} <BR>else <BR>{ <BR>alert('Your browser cannot handle this script'); <BR>} <BR>if (xmlDoc!=null) <BR>{ <BR>xmlDoc.async=false; <BR>xmlDoc.load("person.xml"); <BR>document.write("<table border='1'>"); <BR>var x=xmlDoc.getElementsByTagName("person"); <BR>for (i=0;i<x.length;i++) <BR>{ <BR>document.write("<tr>"); <BR>document.write("<td>"); <BR>document.write( <BR>x[i].getElementsByTagName("myname")[0].childNodes[0].nodeValue); <BR>document.write(""); <BR>document.write("<td>"); <BR>document.write( <BR>x[i].getElementsByTagName("myid")[0].childNodes[0].nodeValue); <BR>document.write(""); <BR>document.write(""); <BR>} <BR>document.write(""); <BR>} <BR> person.xml: 复制代码 代码如下: chwuweig 123456 cig 526636 chwg 524216