这篇文章主要介绍如何使用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> <h3>My CD Collection</h3> <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看效果。大多数浏览器和编程语言都支持的。
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做网页”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。