XSLT Introduction Example


- Info:

- This example shows how to convert XML file into HTML file which uses table to display data from XML file.

- If you have XML file which contains only data, then if you want to display this data in browser you need to add HTML

tags which will tell the browser how certain data should be displayed.


- Procedure:

- Create C:\inetpub\wwwroot\test.xml and test.xsl

- http://localhost/test.xml

- Browser goes to test.xsl and it uses it's commands and data from test.xml to create output file which will be shown.



<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href="test.xsl"?>



<title>Empire Burlesque</title>

<artist>Bob Dylan</artist>





<?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="/">



<h2>My CD Collection</h2>

<table border="1">

<tr bgcolor="#9acd32">

<th align="left">Title</th>

<th align="left">Artist</th>


<xsl:for-each select="catalog/cd">


<td><xsl:value-of select="title" /></td>

<td><xsl:value-of select="artist"/></td>









My CD Collection



Empire Burlesque

Bob Dylan


result in browser