XSLT to transform to CSV
Posted: Fri Sep 02, 2016 11:11 am
I'm trying to use XSLT transform in Switch to convert an XML-file into CSV. I don't know much about XSLT stylesheets, but I managed to find and manipulate this to work for converting my XML to HTML. Could any of you help to make this convert to CSV rather than HTML?
<?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>Bestilling</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Emne</th>
<th style="text-align:left">Navn</th>
</tr>
<xsl:for-each select="textfile/name-value-pair">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="value"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?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>Bestilling</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Emne</th>
<th style="text-align:left">Navn</th>
</tr>
<xsl:for-each select="textfile/name-value-pair">
<tr>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="value"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>