I was asked recently to add the ability to export XML data from our web-based facilities management software. This was so our client could write some of their own scripts that would update their Wiki with some information from our database.
This was simple enough, but then I was asked to add CSV functionality to make it easier to code the simple scripts they would be using at their end, which would run nightly via Cron. Once the XML was working, I didn’t want to write another page so instead, I created a XSLT file that transformed the XML in to neatly formatted CSV text.
The code below is all that was really needed (I have chopped it to only use 2 fields). The fields in this example are delimited by double-quotes.
<xsl:for-each select="//media"> "[<xsl:value-of select="@field1"/>]","<xsl:value-of select="@field2"/>"<br/> </xsl:for-each>