XML入门指南(10)XML数据岛

来源:互联网 发布:hero引擎登陆器源码 编辑:程序博客网 时间:2024/05/16 15:27
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
使用IE5.0或者更高的版本,XML数据可以以数据岛的形式嵌入HTML页面。


在HTML页面中嵌入XML数据

使用非官方标准的<XML>标记可以将XML数据嵌入到HTML页面中。

XML数据可以象下面的例子那样嵌入HTML页面:

<XML id="note"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> </XML>

或者象下面这样嵌入外部单独的XML文件:

<XML id="note" src="note.XML"> </XML>

注意那个<XML>标记是一个HTML元素,而不是一个XML元素。


数据绑定

XML数据岛可以绑定到HTML元素上(比如表格)。

在下面的例子中,一个XML数据岛(ID=cdcat)被从外部XML文档载入。一个HTML的表格绑定到此数据岛上。HTML表格内部的span元素使用datafld属性和XML文档相应的XML元素相互绑定。

<html> <body> <XML id="cdcat" src="cd_catalog.XML"></XML> <table border="1" datasrc="#cdcat"> <tr> <td><span datafld="ARTIST"></span></td> <td><span datafld="TITLE"></span></td> </tr> </table> </body> </html>

如果你使用的是IE 5.0 或者更高版本, 你可以自己尝试一下try it yourself.

如果你使用的是IE 5.0 或者更高版本,你可以观看external XML file.

同样也可以实验this example, 论证元素<thead>, <tbody>, and <tfoot>.

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击