|
Web设计中如何使用XML数据3 |
来源:中国站长学院 人气:1746 录入时间:2007-11-8 |
现在,研究一下下面的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="http://www.blue1000.com/article/#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)
|
|
|