Web设计中如何使用XML数据3
发表时间:2024-06-09 来源:明辉站整理相关软件相关文章人气:
[摘要]现在,研究一下下面的HTML页面: <!-- example3.htm --> <html> <head> <title>XML DSO-example3.htm</title> <script language="JavaScript"> function lo...
现在,研究一下下面的HTML页面:
<!-- example3.htm -->
<html>
<head>
<title>XML DSO-example3.htm</title>
<script language="JavaScript">
function load() {
var xmlDso=myXML.XMLDocument;
xmlDso.load("example3.xml");
}
</script>
</head>
<body bgcolor="#FFFFFF" onLoad="load()">
<object id="myXML" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39"
width="0" height="0"></object>
<table datasrc="#myXML" border="1">
<thead>
<th>Message</th>
<th>URL</th>
</thead>
<tr>
<td><div datafld="message"></div></td>
<td><div datafld="URL"></div></td>
</tr>
</table>
</body>
</html>
输出应是:
Message URL
JavaScript Ticker using XML DSO http://someURL.com
上面的脚本非常特殊化。下面给出一个更一般的脚本:
<script language="JavaScript">
var xmlDso;
function load(xmlFile, objName) {
eval(''xmlDso=''+objName+''.XMLDocument'');
xmlDso.load(xmlFile);
}
</script>
Now, to load any XML file use:
load("SomeXMLFile.xml","anyXmlDsoObject");(csdn)