web设计中如何使用xml数据3

作者:未知 来源:未知 添加时间:2006年7月3日 字体:

  现在,研究一下下面的html页面: 

  <!-- example3.htm -->
  <html>
  <head>
  <title>xml dso-example3.htm</title>
  <script language="&#106avascript">
  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.1fanwen.com/#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
   &#106avascript ticker using xml dso http://someurl.com

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

  <script language="&#106avascript">
  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)

ppdesk