目录
效果:
My CD Collection
首页 后端开发 XML/RSS教程 用xml和xsl做网页实例

用xml和xsl做网页实例

Feb 15, 2017 pm 03:58 PM
xm xsl

          转载请注明来源:用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中文网(m.sbmmt.com)!

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

热AI工具

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

Rimworld Odyssey温度指南和Gravtech
1 个月前 By Jack chen
初学者的Rimworld指南:奥德赛
1 个月前 By Jack chen
PHP变量范围解释了
4 周前 By 百草
撰写PHP评论的提示
3 周前 By 百草
在PHP中评论代码
3 周前 By 百草

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

热门话题

Laravel 教程
1604
29
PHP教程
1509
276
XML模式:PHP中的示例 XML模式:PHP中的示例 Jul 23, 2025 am 12:27 AM

xmlschemavalidationInphpisachsiveDomdocumentAndDomxPathClasseswithThelibxmlextension.1)loadThexmlfilewithdomDocument.2)使用ChemavalidateTeTeTeTaTeTaTeAtaTaTaTaTaTaTaTaTaTAnxSDSSDSSDSCHEMA

如何将外部RSS Feed集成到购物商店 如何将外部RSS Feed集成到购物商店 Jul 24, 2025 am 02:13 AM

TointegrateanexternalRSSfeedintoShopify,firstverifythefeed’svalidityandformatting.2.UsecustomJavaScriptwithaproxyAPIlikeRSS2JSONtofetchanddisplaythefeedinaLiquidtemplate,asShopifylacksnativesupport.3.Alternatively,useano-codeShopifyappsuchasBlog&

XML名称空间:Web服务的最佳实践 XML名称空间:Web服务的最佳实践 Jul 14, 2025 am 12:03 AM

ThebestpracticesforusingXMLnamespacesinwebservicesare:1)UsemeaningfulnamespaceURIs,2)Useshortanddescriptiveprefixes,3)Consistentlyapplynamespaces,4)Avoidoverusingnamespaces,5)Documentnamespaces,and6)Considerperformanceimplications.Thesepracticesensur

XML对开发人员的好处:简单,灵活性和可移植性 XML对开发人员的好处:简单,灵活性和可移植性 Jul 20, 2025 am 03:59 AM

Xmlbenefitsdeveloperswithitssimplicity,柔韧性和通用性。1)Itshuman-RearableFormataidsIneasyDebugging.2)customizabletagsallowforadaptabledabledstrastures.3)平台独立性依赖性experenceenceenceensemensemensemensemenseamemenseamemenseamemelessememsemlessemlessdataexchangeaChangeAcrosssystems。

XML性能:这是一个好决定吗? XML性能:这是一个好决定吗? Jul 15, 2025 am 01:07 AM

xml'ssuitabilityforporformance-Criticalapplicationsdeppecifications.1)Xml'sparsingoverheadCanbesbesigantificant

XML:如果我不验证我的成型XML怎么办? XML:如果我不验证我的成型XML怎么办? Jul 21, 2025 am 02:28 AM

Notvalidatingwell-formedXMLcanleadtoseriousissues.1)Dataintegrityerrorsoccurwithoutvalidation.2)InteroperabilityissuesariseassystemsmayinterpretXMLdifferently.3)SecurityrisksincreaseduetopotentialexploitationbymaliciousXML.Alwaysuseschemasandautomate

XML写作规则:避免常见错误 XML写作规则:避免常见错误 Jul 21, 2025 am 01:50 AM

CommonXMLerrorsincludemismatchedtags,impropernesting,unquotedattributevalues,casesensitivityissues,invalidcharacters,andmisuseddeclarations.Toavoidthese:1)UseXMLeditorswithsyntaxhighlightingandauto-completiontopreventmismatchedtags.2)Mentallystructur

将XML转换为Python词典 将XML转换为Python词典 Jul 25, 2025 am 01:24 AM

使用xmltodict是将XML转换为Python字典的推荐方法,1.安装xmltodict库:pipinstallxmltodict;2.使用xmltodict.parse()将XML字符串解析为字典,自动处理嵌套元素、重复标签和属性;3.可通过attr_prefix参数自定义属性前缀;若无法安装第三方库,可使用内置的xml.etree.ElementTree,通过递归函数将Element对象转换为字典,但需手动处理列表、属性和文本节点;注意处理空元素、类型转换、命名空间及大文件时的性能问题,

See all articles