Quantcast
Channel: converting XML to CSV format
Viewing all articles
Browse latest Browse all 3

converting XML to CSV format

$
0
0

Thanks hgen_banks

 

Here is the XML and XSL that I was able to use

 

<?xml version="1.0"?>
  <D>
  <D1 ID="1" NAME="NEERAJ" SCORE="8"/>
  <D2 ID="2" NAME="RAJAT" SCORE="4"/>
  <D3 ID="3" NAME="VINAY" SCORE="9"/>
  </D>

 

 

and XSL to convert to CSV

 

<xslTongue Tiedtylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslSurpriseutput method="text"/>
<xsl:template match="D">
<xsl:apply-templates select="node()"/>
</xsl:template>
<xsl:template match="node()">
<xsl:for-each select="@*">
<xsl:text>&#34;</xsl:text>
<xsl:value-of select="."/>
<xsl:text>&#34;</xsl:text>
<xsl:if test="position() != last()">
<xsl:value-of select="','"/>
</xsl:if>
</xsl:for-each>
<xsl:text>&#10;</xsl:text>
</xsl:template>
</xslTongue Tiedtylesheet>

 

 

Output:

 

"1","NEERAJ","8"
"2","RAJAT","4"
"3","VINAY","9"

 

Output


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>