简单问题:HTML中不能显示XML中的数据(20分)

Z

zsy146

Unregistered / Unconfirmed
GUEST, unregistred user!
我是新学XML的,现在有如下代码,HTML中不能显示XML中的数据,请问是什么原因?在写代码的过程中要注意什么问题?
<!-- books.htm -->
<html>
<Head><title>Books</title></Head>
<Body>
<XML ID=&quot;XMLbook&quot;
SRC=&quot;books.xml&quot;></XML>
<table DATASRC =&quot;#XMLbook&quot;
border = &quot;1&quot;
Cellpadding=&quot;5&quot;>
<thead><th>title</th><th>isbn</th></thead>
<tr>
<td><span DTATFLD= &quot;title&quot;></span></td>
<td><span DTATFLD= &quot;isbn&quot;></span></td>
</tr>
</table>
</Body>
</html>
************************************************
<!--books.xml-->
<?xml version=&quot;1.0&quot;
encoding=&quot;GB2312&quot;?>
<booklist>
<book>
<title>Straight Talk About Computers</title>
<isbn>72-80088-005</isbn>
</book>
<book>
<title> Gourmet Microwave </title>
<isbn>72-80081-082</isbn>
</book>
</booklist>
 
Z

zsy146

Unregistered / Unconfirmed
GUEST, unregistred user!
有些概念性的东西不太清楚,找了些资料看了,没有什么头绪,希望各位推荐点书籍也行.
 
Z

zsy146

Unregistered / Unconfirmed
GUEST, unregistred user!
如下的可以正常显示:(我有什么没有注意到的吗?望指点.)
<!-- File Name: Inventory Table.htm -->
<HTML>
<HEAD>
<TITLE>Book Inventory</TITLE>
</HEAD>
<BODY>
<XML ID=&quot;dsoInventory&quot;
SRC=&quot;Inventory.xml&quot;></XML>
<H2>Book Inventory</H2>
<TABLE DATASRC=&quot;#dsoInventory&quot;
BORDER=&quot;1&quot;
CELLPADDING=&quot;5&quot;>
<THEAD>
<TH>Title</TH>
<TH>Author</TH>
<TH>Binding</TH>
<TH>Pages</TH>
<TH>Price</TH>
</THEAD>
<TR ALIGN=&quot;center&quot;>
<TD><SPAN DATAFLD=&quot;TITLE&quot;
STYLE=&quot;font-style:italic&quot;></SPAN></TD>
<TD><SPAN DATAFLD=&quot;AUTHOR&quot;></SPAN></TD>
<TD><SPAN DATAFLD=&quot;BINDING&quot;></SPAN></TD>
<TD><SPAN DATAFLD=&quot;ID&quot;></SPAN></TD>
<TD><SPAN DATAFLD=&quot;PRICE&quot;></SPAN></TD>
</TR>
</TABLE>
</BODY>
</html>
*********************************************
<?xml version=&quot;1.0&quot;?>
<!-- File Name: Inventory.xml -->
<INVENTORY>
<BOOK>
<TITLE>The Adventures of Huckleberry Finn</TITLE>
<AUTHOR>Mark Twain</AUTHOR>
<BINDING>mass market paperback</BINDING>
<ID>298</ID>
<PRICE>$5.49</PRICE>
</BOOK>
<BOOK>
<TITLE>Leaves of Grass</TITLE>
<AUTHOR>Walt Whitman</AUTHOR>
<BINDING>hardcover</BINDING>
<ID>462</ID>
<PRICE>$7.75</PRICE>
</BOOK>
</INVENTORY>
 
Z

zjan521

Unregistered / Unconfirmed
GUEST, unregistred user!
//<td><span DTATFLD= &quot;title&quot;></span></td>
拼写错误,应该是DATAFLD,不是DTATFLD
 
Z

zsy146

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢了,我一直没有在这个上面检查.
 
Z

zsy146

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
Z

zsy146

Unregistered / Unconfirmed
GUEST, unregistred user!
成功的代码:
<!-- books.htm -->
<html>
<Head><title>Books</title></Head>
<Body>
<XML ID=&quot;XMLbook&quot;
SRC=&quot;books.xml&quot;></XML>
<table DATASRC =&quot;#XMLbook&quot;
border = &quot;1&quot;
Cellpadding=&quot;5&quot;>
<thead><th>title</th><th>isbn</th></thead>
<tr>
<td><span DATAFLD= &quot;title&quot;></span></td>
<!--错误时为:DTATFLD-->
<td><span DATAFLD= &quot;isbn&quot;></span></td>
</tr>
</table>
</Body>
</html>
************************************************
<!--books.xml-->
<?xml version=&quot;1.0&quot;
encoding=&quot;GB2312&quot;?>
<booklist>
<book>
<title>Straight Talk About Computers</title>
<isbn>72-80088-005</isbn>
</book>
<book>
<title> Gourmet Microwave </title>
<isbn>72-80081-082</isbn>
</book>
</booklist>
 
顶部