转载请注明来源:用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

Title Artist
Empire Burlesque Bob Dylan
Empire Burlesqu2e Bob Dyla2n
Empire Burlesqu2e Bob Dyla2n
Empire Burlesqu2e Bob Dyla2n
Empire Burlesqu2e Bob Dyla2n
Empire Burlesqu2e Bob Dyla2n

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

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

  • 相关标签:xm xsl 网页实例
  • 程序员必备接口测试调试工具:点击使用

    Apipost = Postman + Swagger + Mock + Jmeter

    Api设计、调试、文档、自动化测试工具

    网页生成APP,用做网站的技术去做APP:立即创建

    手机网站开发APP、自助封装APP、200+原生模块、2000+映射JS接口按需打包

    • 上一篇:xml——json
    • 下一篇:XML解析之sax解析案例(二)使用sax解析把 xml文档封装成对象

    相关文章

    相关视频


    • 使用xmlhttp为网站增加域名查询功能的示例代码...
    • 四种XML解析方式详解
    • 基于PHP对XML的操作详解
    • XML和Tomcat的入门知识的详细介绍
    • 用xml和xsl做网页实例
    • PHP XML Expat
    • XML DOM
    • PHP XML Expat 解析器
    • PHP SimpleXML
    • PHP SimpleXML

    视频教程分类

    • php视频教程
    • html视频教程
    • css视频教程
    • JS视频教程
    • jQuery视频教程
    • mysql视频教程
    • Linux视频教程
    • Python视频教程
    • Laravel视频教程
    • Vue视频教程

    专题

    用xml和xsl做网页实例