究一下下面的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)