xml数据岛
<?xml version= "1.0 " encoding= "ISO-8859-1 "?>
<CATALOG>
<CD>
<TITLE> Empire Burlesque </TITLE>
<ARTIST> Bob Dylan </ARTIST>
<COUNTRY> USA </COUNTRY>
<COMPANY> Columbia </COMPANY>
<PRICE> 10.90 </PRICE>
<YEAR>
<TT> 1985 </TT>
</YEAR>
</CD>
<CD>
<TITLE> Hide your heart </TITLE>
<ARTIST> Bonnie Tyler </ARTIST>
<COUNTRY> UK </COUNTRY>
<COMPANY> CBS Records </COMPANY>
<PRICE> 9.90 </PRICE>
<YEAR> <TT> 1988 </TT> </YEAR>
</CD>
</CATALOG>
test.html中我想显示 <YEAR> 中的 <TT> ,请问如何显示.
<html>
<body>
<xml id= "cdcat " src= "test.xml ">
</xml>
<table border= "1 " datasrc= "#cdcat ">
<tr> <td> <span datafld= "TITLE ">
</span> </td> <td
<span datafld= "TT "> </span>
td> </tr> </table> </body> </html>
只能出现 <TITLE> 内容,可是不能出现 <TT> 的内容!
[解决办法]
解决:
<html>
<head>
<title>多层XML数据岛测试</title>
</head>
<body>
<xml id="cdcat">
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>
<TT>1985</TT>
</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>
<TT>1988</TT>
</YEAR>
</CD>
</CATALOG>
</xml>
<table border="1" datasrc="#cdcat">
<tr>
<td>
<span datafld="TITLE"></span>
</td>
<td>
<table border="0" datasrc="#cdcat" datafld="YEAR">
<tr>
<td>
<span datafld="TT"></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<button onclick="alert(document.all.cdcat.xml);">显示数据源</button>
</body>
</html>