为什么调用我的dwb()函数后,页面就会显示一个开始?

wudichaoren2010 wudichaoren2010 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


<?xml version="1.0" encoding="utf-8"?>
<students>
<stu>
<id>a1</id>
<name>赵</name>
<c>name</c>
</stu>

<stu>
<id>a2</id>
<name>钱</name>
<c>90</c>
</stu>

<stu>
<id>a3</id>
<name>孙</name>
<c>87</c>
</stu>

<stu>
<id>a4</id>
<name>李</name>
<c>66</c>
</stu>

<stu>
<id>a5</id>
<name>周</name>
<c>31</c>
</stu>

<stu>
<id>a6</id>
<name>吴</name>
<c>78</c>
</stu>
</students>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>LJ读取</title>

<script type="text/javascript">
function dwb(message)
{
return document.write(message+"<br />");
}

/*
function loadXMLDoc(dname) {
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
}
else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET", dname, false);
xhttp.send("");
return xhttp.responseXML;
}
*/
function ReadXml() {
dwb("开始");
/*
var myxmlDom = new ActiveXObject("Microsoft.XMLDOM");
myxmlDom.async=false;
myxmlDom.load("score.xml");
*/
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async=false;
xmldoc.load("score.xml");
//var xmldoc = loadXMLDoc("score.xml");
//获得指定节点
var divmsg = document.getElementById("xmlMsg");
var msg = "<table border='1' id='mytable'><tr><th>姓名</th><th>性别</th><th>年龄</th><tr>";

/*
tb1.innerHTML=myxmlDom.documentElement.childNodes[i].childNodes[0].firstChild.nodeValue;
tb2.innerHTML=myxmlDom.documentElement.childNodes[i].childNodes[1].firstChild.nodeValue;
tb3.innerHTML=myxmlDom.documentElement.childNodes[i].childNodes[2].firstChild.nodeValue;

*/

dwb(xmldoc.documentElement.childNodes.length);

for (var i = 0; i < 5; i++) {
msg += "<tr>";
msg += "<td>" + xmldoc.documentElement.childNodes[i].childNodes[0].firstChild.nodeValue + "</td>";
msg += "<td>" + xmldoc.documentElement.childNodes[i].childNodes[1].firstChild.nodeValue + "</td>";
msg += "<td>" + xmldoc.documentElement.childNodes[i].childNodes[2].firstChild.nodeValue + "</td>";
msg += "</tr>";
}
msg += "</table>";
divmsg.innerHTML = msg;


/*
var nodes = xmldoc.getElementsByTagName("stuinfo");
for (var i = 0; i < nodes.length; i++) {
msg += "<tr>";
msg += "<td>" + nodes[i].getElementsByTagName("stuName")[0].firstChild.nodeValue + "</td>";
msg += "<td>" + nodes[i].getElementsByTagName("stuSex")[0].firstChild.nodeValue + "</td>";
msg += "<td>" + nodes[i].getElementsByTagName("stuAge")[0].firstChild.nodeValue + "</td>";
msg += "</tr>";
}
msg += "</table>";
divmsg.innerHTML = msg;
*/
}
</script>
</head>


<body>
<form id="form1" runat="server">
<div>
<input type="button" value="JS读取XML" onclick="ReadXml()" /><br />
<div id="xmlMsg">
</div>
</div>
</form>
</body>



</html>



求助,为什么调用我的dwb()函数后,页面就会显示一个开始?
...全文

相关推荐

评论 16
收藏 已收藏
分享
返回顶部
wudichaoren2010
JavaScript 87,983 成员 224,680 内容