javascript将xml文件绑定到table上

<html>
<head>
<title>绑定到Table</title>
</head>
<body>
<xml id="cdcat" src="被绑定table.xml" tppabs="将XML文件绑定到Table.xml"></xml>
<table border="1" datasrc="#cdcat">
<thead>
<tr><th>演唱者</th><th>歌名</th></tr>
</thead>
<tfoot>
<tr><th colspan="2">这是我喜欢的CD</th></tr>
</tfoot>
<tbody>
<tr>
<td><span datafld="artist"></span></td>
<td><span datafld="title"></span></td>
</tr>
</tbody>
</table>
</body>
</html>

 

被绑定table.xml文件如下:

<?xml version="1.0" encoding="utf-8" ?>
<cd>
   <cdcat>
      <artist>jay</artist>
      <title>她的睫毛</title>
   </cdcat>
   <cdcat>
      <artist>Eason</artist>
      <title>爱情呼叫转移</title>
   </cdcat>

</cd>

 

 

上述代码使用了Web设计中XML数据岛的相关知识,要注意标注同样颜色的代码。

原文地址:https://www.cnblogs.com/ccsbb/p/2032023.html