xsl not formating xml file correctly into csv file
-
Hi all, I want to collect some data(not all) from an xml file and write them into a csv file. I used a xsl file formatting for that. Here is my xml file content.
<?xml version="1.0" encoding="ISO-8859-1"?> <MAIN> <CATALOG> <PLANT Tag="no"> <LIGHT>Time may differ</LIGHT> <PRICE>$2.44</PRICE> </PLANT> <PLANT Tag="no"> <LIGHT>Fixed time</LIGHT> <PRICE>$9.37</PRICE> </PLANT> </CATALOG> <CHAT> <SOME>Some Text</SOME> <MORE>More Text</MORE> </CHAT> </MAIN>
I want to get data on CATALOG element. So here is my style sheet.<?xml version="1.0"?> <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <!--<xsl:strip-space elements = "CATALOG"/>--> <xsl:template match="/MAIN/CATALOG/PLANT"> <!--<xsl:text/><xsl:value-of select="normalize-space(PLANT)"/>"<xsl:text/>--> <xsl:value-of select="normalize-space(LIGHT)"/>";"<xsl:text/> <xsl:value-of select="normalize-space(PRICE)"/>" <xsl:text/> <xsl:text disable-output-escaping = "yes" ></xsl:text> </xsl:template> </xsl:stylesheet>
But what happened here is, data on CHAT element also added to the file. I only want data on <LIGHT> and <PRICE> elements. But my style sheet gives data on <SOME> and <MORE> elements. How can I correct this. Please help me too fix this. I'm stuck with this for two days. ThanksI appreciate your help all the time... CodingLover :)