XML to csv transformation

Hi,

I want to write a perl script. Which should accept the xml file, one xsl file and the loaction. The perl script should process the xml file using the xsl file and puts the out put in specified location.

For example:

My.perl is perls cript.
my.xml
is like this

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<!--  Edited by XMLSpy�   --> 
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
 <catalog>
	<cd>
	      <title>Empire Burlesque</title> 
	      <artist>Bob Dylan</artist> 
	      <country>USA</country> 
	  </cd>
              <cd>
	     <title>Private Dancer</title> 
	     <artist>Tina Turner</artist> 
	    <country>UK</country> 
	    <company>Capitol</company> 
             </cd>
  </catalog>

test.xsl is

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table border="1">
<xsl:for-each select="catalog/cd">
	<tr>
		<td>
		<xsl:value-of select="."/>
		</td>
	</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

When I execute the perl script
my.perl my.xml test.xsl /root/siba/a.txt

Then It will save the out put in /root/siba/a.txt
The a.txt would be like this

Empire Burlesque Bob Dylan USA Columbia 10.90 1985  
Private Dancer Tina Turner UK Capitol 8.90 1983  

Please suggect some idea, how can write the script.

please refer to CPAN XML::XSLT, which is a perl xslt processor.

Or you may use another c version xsl processor 'xsltproc', which accept two parameters xml and xsl, output result.

Thanks a lot. I used XML::LibXSLT. Now it works fine.