相思资源网 Design By www.200059.com
person.htm:
复制代码 代码如下:
<html>
<body>
<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{
// for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{
//for Mozilla, Firefox, Opera,
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("person.xml");
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("person");
for (i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("myname")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("myid")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</body>
</html>
person.xml:
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<root>
<person>
<myname>chwuweig</myname>
<myid>123456</myid>
</person>
<person>
<myname>cig</myname>
<myid>526636</myid>
</person>
<person>
<myname>chwg</myname>
<myid>524216</myid>
</person>
</root>
复制代码 代码如下:
<html>
<body>
<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{
// for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{
//for Mozilla, Firefox, Opera,
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("person.xml");
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("person");
for (i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("myname")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("myid")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</body>
</html>
person.xml:
复制代码 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<root>
<person>
<myname>chwuweig</myname>
<myid>123456</myid>
</person>
<person>
<myname>cig</myname>
<myid>526636</myid>
</person>
<person>
<myname>chwg</myname>
<myid>524216</myid>
</person>
</root>
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无javascript XML数据显示为HTML一例的评论...