位置:海鸟网 > IT > XML >

Web设计中如何使用XML数据3

 现在,研究一下下面的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

  上面的脚本非常特殊化。下面给出一个更一般的脚本:

  <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