<?xml version="1.0" encoding="UTF-8"?> <resume> <name>mike</name> <age>29</age> </resume>
html的檔案是如下的這個樣子:
HTML code:
<html> <body> <XML id="myds" src="kg.xml"></XML> <table datasrc="myds"> <tr> <td><div datafld="resume:name"/></div></td> <td><div datafld="name"/></div></td> <td><div datafld="age"/></div></td> </tr> </table> </body> </html>
要避免上面的問題,有兩點需要修改的地方:
1. datasrc=”# 這裡我漏掉了#1號使用span.
如下是修改後的準確的代碼細節:
XML code:
<?xml version="1.0" encoding="UTF-8"?> <resume> <name>mike</name> <age>29</age> </resume>
<xml id="XMLData" src="test.xml"></xml> <table id="tblbooks" datasrc="#XMLData" border=1 datapagesize=2 width="100%"> <thead> <th style="font-style: blod">姓名</th> <th style="font-style: blod">年纪</th> </thead> <tr> <td><span datafld="name"></span></td> <td><span datafld="age"></span></td> </tr> </table>