转载请注明来源:用xml和xsl做网页实例

用xml和xsl做网页。直接大家保存两个文件运行即可。

cdcatalog.xml 相当于html
cdcatalog.xsl 相当于css



cdcatalog.xml

[html] view plaincopy

<?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="http://www.php1.cn/"> <catalog>   <cd>     <title>Empire Burlesque</title>     <artist>Bob Dylan</artist>     <country>USA</country>     <company>Columbia</company>     <price>10.90</price>     <year>1985</year>   </cd>  <cd>     <title>Empire Burlesqu2e</title>     <artist>Bob Dyla2n</artist>     <country>USA2</country>     <company>Columbia2</company>     <price>10.91</price>     <year>1983</year>   </cd> <cd>     <title>Empire Burlesqu2e</title>     <artist>Bob Dyla2n</artist>     <country>USA2</country>     <company>Columbia2</company>     <price>10.91</price>     <year>1983</year>   </cd> <cd>     <title>Empire Burlesqu2e</title>     <artist>Bob Dyla2n</artist>     <country>USA2</country>     <company>Columbia2</company>     <price>10.91</price>     <year>1983</year>   </cd> <cd>     <title>Empire Burlesqu2e</title>     <artist>Bob Dyla2n</artist>     <country>USA2</country>     <company>Columbia2</company>     <price>10.91</price>     <year>1983</year>   </cd> <cd>     <title>Empire Burlesqu2e</title>     <artist>Bob Dyla2n</artist>     <country>USA2</country>     <company>Columbia2</company>     <price>10.91</price>     <year>1983</year>   </cd> </catalog>





cdcatalog.xsl

[html] view plaincopy

<?xml version="1.0" encoding="ISO-8859-1"?>  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <xsl:template match="/">   <html>   <body>     <h2>My CD Collection</h2>     <table border="1">     <tr bgcolor="#9acd32">       <th align="left">Title</th>       <th align="left">Artist</th>     </tr>     <xsl:for-each select="catalog/cd">     <tr>       <td><xsl:value-of select="title"/></td>       <td><xsl:value-of select="artist"/></td>     </tr>     </xsl:for-each>     </table>   </body>   </html> </xsl:template>  </xsl:stylesheet>





用浏览器打开cdcatalog.xml看效果。大多数浏览器和编程语言都支持的。

效果:

My CD Collection

TitleArtist
Empire BurlesqueBob Dylan
Empire Burlesqu2eBob Dyla2n
Empire Burlesqu2eBob Dyla2n
Empire Burlesqu2eBob Dyla2n
Empire Burlesqu2eBob Dyla2n
Empire Burlesqu2eBob Dyla2n

以上就是用xml和xsl做网页实例的内容,更多相关内容请关注PHP中文网(www.php.cn)!

更多相关文章

  1. xml学习(6) 在c#Xpath实例
  2. XPath 11个实例
  3. 从XML中读取数据到内存的实例
  4. 实例简析XPath串函数和XSLT
  5. 使用正则表达式进行xml数据验证的代码实例详解
  6. 基于XML的购物车的实例代码详情
  7. HTML中的XML数据岛记录编辑与添加代码实例详细介绍
  8. 利用XML开发留言板简单的实例代码解析
  9. 通过XML数据岛和Dom制作通讯录的代码实例详解

随机推荐

  1. 一文上手 Elasticsearch常用可视化管理工
  2. Kafka底层原理剖析(近万字建议收藏)
  3. 自然语言处理工具包 HanLP在 Spring Boot
  4. 注册中心 Eureka源码解析 —— 应用实例
  5. 老艿艿说:关于时间管理的分享
  6. 分布式作业系统 Elastic-Job-Lite 源码分
  7. 如何使用Python实现FTP服务器?Python学习
  8. CentOS7 上搭建多节点 Elasticsearch集群
  9. 分布式做系统 Elastic-Job-Lite 源码分析
  10. yarn-site.xml的部分资源配置参数,主要是