XML
<?xml version="1.0" encoding="GB2312"?>
<myfile>
<title>tttt</title>
<author>QinHao</author>
<email>leo-qh@163.com</email>
<date>20080201</date>
</myfile>JS:
<html>
<head>
<script language="JavaScript" for="window" event="onload">...
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("myfile.xml");
root = xmlDoc.documentElement;
//nodes = xmlDoc.documentElement.childNodes;
document.all("title").innerText = root.childNodes.item(0).text;
document.all("author").innerText = root.childNodes.item(1).text;
document.all("email").innerText = root.childNodes.item(2).text;
document.all("date").innerText = root.childNodes.item(3).text;
</script>
<title>在HTML中调用XML数据</title>
</head>
<body bgcolor="#FFFFFF">
<b>标题: </b>
<span id="title"> </span><br>
<b>作者: </b>
<span id="author"></span><br>
<b>信箱: </b>
<span id="email"></span><br>
<b>日期:</b>
<span id="date"></span><br>
</body>
</html>

被折叠的 条评论
为什么被折叠?



