Jump to content

XML output on XSL with table


Recommended Posts

I would like to have my stylesheet use an XML output and if possible use it with a table. I seem to only get this to work with a HTML output not a XML output. I am fairly new at XML so any examples of how to do this or suggestions would be greatly appreciated.


Here is my XML code


<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="Lesson_8_obj_1.xsl" type="text/xsl"?><!DOCTYPE Employees><Employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="xsd.xsd">> <Employee> <First>John</First> <Last>Smith</Last> <Phone Type="Home">1-800-123-4567</Phone> <Birthday>1960-05-25</Birthday> <HourlyRate>35.85</HourlyRate></Employee> <Employee> <First>Jane</First> <Last>Jones</Last> <Phone Type="Cell">1-800-999-9999</Phone> <Birthday>1980-11-01</Birthday> <HourlyRate>58.17</HourlyRate></Employee></Employees>


Here is my XSL code.



<?xml version="1.0" ?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" indent="yes"/>

<xsl:template match="/"><table> <tr> <th>First</th> <th>Last</th> <th>Phone</th> <th>Birthday</th> <th>HourlyRate</th> </tr><xsl:for-each select="Employees/Employee"> <tr> <td><xsl:value-of select="First"/></td> <td><xsl:value-of select="Last"/></td> <td><xsl:value-of select="Phone"/></td> <td><xsl:value-of select="Birthday"/></td> <td><xsl:value-of select="HourlyRate"/></td></tr></xsl:for-each> </table> </xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...