Dùng XML để hiển thị dữ liệu trong XSLT
Dùng XML để hiển thị dữ liệu trong XSLT,truyền dữ liệu bằng XML,cách đọc dữ liệu XML trong lập trình,lập trình XML, lập trình XSLT<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="diaCD.xslt" ?> <!--đường dẫn đến file xslt để kết nối-->
<class>
<cd>
<title>Giay phut chia xa</title>
<artist>Don ba dao</artist>
<country>us</country>
<company>us</company>
<price>80k</price>
<year>1995</year>
</cd>
<cd>
<title>chem gio</title>
<artist>tho thieu thon</artist>
<country>us</country>
<company>us</company>
<price>1k</price>
<year>2014</year>
</cd>
</class>
File XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="html" />
<xsl:template match="/">
<table border="1">
<tr bgcolor="#9acd32">
<td>title</td>
<td> artist</td>
<td> country</td>
<td> company</td>
<td> price</td>
<td> year</td>
</tr>
<xsl:for-each select ="class/cd">
<tr>
<td>
<xsl:value-of select="title"></xsl:value-of>
</td>
<td>
<xsl:value-of select="artist"></xsl:value-of>
</td>
<td>
<xsl:value-of select="country"></xsl:value-of>
</td>
<td>
<xsl:value-of select="company"></xsl:value-of>
</td>
<td>
<xsl:value-of select="price"></xsl:value-of>
</td>
<td>
<xsl:value-of select="year"></xsl:value-of>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment