加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

XML使用XSL样式表在浏览器中以XHTML样式展示

发布时间:2020-12-16 05:55:34 所属栏目:百科 来源:网络整理
导读:从一个原始的 XML(cdcatalog.xml)文档开始 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ? xml version = "1.0" encoding = "ISO-8859-1" ? catalog cd title Empire Burlesque /title uri www.akmumu.com /uri country USA /country company Columbia /company price

从一个原始的 XML(cdcatalog.xml)文档开始

这时候使用浏览器访问xml文件,会以各浏览器的标准xml样式展示,有的时候我们需要以自己定义的样式预览,比如定义一个a标签,里面有xml的链接,并可以点击,这时候我们需要建立一个XSL(cdcatalog.xsl) 样式表文件如下:

这时候我们只需要向原xml文件增加一行
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
如:

14
15
<? "ISO-8859-1" ?>
<? xml - stylesheet type = "text/xsl" href = "cdcatalog.xsl" ?>
<catalog>
<cd>
<title> Empire Burlesque </title>
<uri> www.akmumu.com </uri>
<country> USA </country>
<company> Columbia </company>
<price> 10.90 </price>
<year> 1985 </year>
</cd>
.
.
.
</catalog>

再从浏览器访问xml文件,样式出现了,a链接可以直接点击。完毕!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

相关内容
推荐文章
站长推荐
热点阅读