XML数据岛

在HTML中,可以通过<xml>标记嵌入XML文档或引用一个外部XML文档,这部分嵌入HTML页面中的XML数据称为XML数据岛。
XML数据岛的使用仅限于IE浏览器。
创建XML对象后,可以与HTML文档中的table、span、div等元素绑定,绑定元素的datasrc属性为XML元素的id属性,前面要加上“#”;datafld属性为要显示的字段内容。
booklist.xml
<? xml version="1.0" encoding="UTF-8" ?>
< booklist >
< book >
< name > Ajax </ name >
< price > $5.95 </ price >
< description > Foundations of Ajax. </ description >
</ book >
< book >
< name > Ajax Patterns </ name >
< price > $7.95 </ price >
< description > Introduction of Ajax Patterns. </ description >
</ book >
< book >
< name > Ajax Web App </ name >
< price > $8.95 </ price >
< description > Edition 2. </ description >
</ book >
< book >
< name > Core CSS </ name >
< price > $4.50 </ price >
< description > A book for CSS. </ description >
</ book >
< book >
< name > JSF and Ajax </ name >
< price > $6.95 </ price >
< description > Apress. </ description >
</ book >
</ booklist >
booklist.html
< html >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=UTF-8" >
< title > XML数据岛 </ title >
</ head >
< body >
XML data begin:
< br >
< xml  id ="MyBookList"  src ="booklist.xml" ></ xml >
< table  datasrc ="#MyBookList"  border ="1" >
< thead >
    
< th > name </ th >
    
< th > price </ th >
    
< th > description </ th >
</ thead >
< tr  align ="left" >
    
< td >< span  datafld ="name" ></ span ></ td >
    
< td >< span  datafld ="price" ></ span ></ td >
    
< td >< span  datafld ="description" ></ span ></ td >
</ tr >
</ table >
</ body >
</ html >
运行结果:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值