1. Following XML is received as input
<?xml version="1.0" encoding="UTF-8"?>
<Teams>
<team>
<title>Real Madrid</title>
<country>Spain</country>
</team>
<team>
<title>Arsenal Londra</title>
<country>England</country>
</team>
</Teams>
2. Following code is transforming the above XML into HTML format:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2 style="font-family:arial">European Football Teams</h2>
<table border="0" style="font-family:arial">
<tr bgcolor="#9a0000" style="color:#fff">
<th style="text-align:left">Name</th>
<th style="text-align:left">Country</th>
</tr>
<xsl:for-each select="Teams/team">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="country"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
3. And the HTML output:
No comments:
Post a Comment