StefanK over at MacScripter posted an AppleScript XML to CSV solution. Copy and paste his second (04:54:35 am) example code (that writes a CSV data file) into your AppleScrpt editor, compile, and then save as a Text (xml2csv.applescript) document. Run it, and it will prompt you for your XML data file. When it is done parsing that, it will then prompt you for a filename to save too. You can also save it as an App on your Desktop. The output format is your preferred result.
There are Python and Ruby solutions that are much shorter in code, and easier to understand — but require non-standard library and gem installations — something I avoid in posted solutions, so I have omitted these here.
Another solution is to use an XSLT stylesheet with the OS X xsltproc command line XSLT processor. If we use the data format that you provided, and place it in an asc.xml file, and apply the test.xsl XSLT stylesheet — the following syntax will provide the desired output:
xsltproc test.xsl asc.xml > asc.csv
Result:
OrderID,CreationDate
123,27/06/2014
146,30/06/2014
The idea (and code) for the following XSLT stylesheet came from here.
test.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="iso-8859-1"/>
<!-- The first code block will dynamically obtain the tag names and
use them in the header CSV row. The second code block captures the
tag data, and outputs it in newline "
" rows. If the destination
of the output is on Windows, then the line termination should be
"
"
If it is desired to place quotes around the header, and data CSV
items, then uncomment the <xsl:text>"</xsl:text> blocks.
-->
<xsl:template match="/*">
<xsl:for-each select="*[1]/*">
<!-- <xsl:text>"</xsl:text> -->
<xsl:value-of select="name()"/>
<!-- <xsl:text>"</xsl:text> -->
<xsl:if test="position() != last()">,</xsl:if>
<xsl:if test="position() = last()">
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:template>
<xsl:strip-space elements="*" />
<xsl:template match="/*/child::*">
<xsl:for-each select="child::*">
<xsl:if test="position() != last()"><!--<xsl:text>"</xsl:text>-->
<xsl:value-of select="normalize-space(.)"/><!--<xsl:text>"</xsl:text>-->,</xsl:if>
<xsl:if test="position() = last()"><!--<xsl:text>"</xsl:text>-->
<xsl:value-of select="normalize-space(.)"/><!--<xsl:text>"</xsl:text>-->
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>