Hi i do have following xml code: Then i need to convert those xml to csv format with header title is show.
Try this XSLT to get your desired output:
<xsl:template match="portfolio">
<xsl:text>"Name";"Price"</xsl:text>
<xsl:text> </xsl:text>
<xsl:for-each select="stock">
<xsl:text>"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>";</xsl:text>
<xsl:text>"</xsl:text>
<xsl:value-of select="price"/>
<xsl:text>"</xsl:text>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
This is my last script:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="portfolio">
<xsl:text>"Name"</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>;</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>"Price"</xsl:text><br/>
<xsl:for-each select="//stock[@exchange='nasdaq']">
<xsl:text>"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"</xsl:text><xsl:text> </xsl:text>
<xsl:text>;</xsl:text>
<xsl:text> </xsl:text>
<xsl:text>"</xsl:text>
<xsl:value-of select="price"/>
<xsl:text>"</xsl:text><br/>
</xsl:for-each>
</xsl:template>
Its work fine to filter out the info and making new line for csv output! =)