I need a software for converting xml files to csv. It has to run on Windows Server 2012 / 2016 on command line. The software must have good support (updates, live help etc..)
1 Answer
You can use this XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="iso-8859-1"/>
<xsl:strip-space elements="*" />
<xsl:template match="/*/child::*">
<xsl:for-each select="child::*">
<xsl:if test="position() != last()">"<xsl:value-of select="normalize-space(.)"/>", </xsl:if>
<xsl:if test="position() = last()">"<xsl:value-of select="normalize-space(.)"/>"<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
And use xsltproc with this stylesheet to convert to CSV. For reference you can check this answer: https://stackoverflow.com/a/365338/2908599
Also you can try this tool xml2csv, it seems reported by people as working well.