Convert xml to csv

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have extracted data from a SQL database and need to convert it to a csv. I
have transformed the data to xml and then save it with .xls extension which
is viewable in Excel. As soon as I try save the xml to a csv, I view all the
tags when I open the document in Excel.

Please could some one assist with a possible better solution.

Thanks in advance
 
I have extracted data from a SQL database and need to convert it to a csv. I
have transformed the data to xml and then save it with .xls extension which
is viewable in Excel. As soon as I try save the xml to a csv, I view all the
tags when I open the document in Excel.

One simple way is to use a style sheet to transform the XML into CSV using
XslTransform.

I'm sure Excel has got some import options to import XML and turn it into a
proper spreadsheet though

James
 
James Mahoney said:
One simple way is to use a style sheet to transform the XML into CSV using
XslTransform.

I'm sure Excel has got some import options to import XML and turn it into a
proper spreadsheet though

James

If I may so be so bold as to where I might obtain sample code for this. I
have looked through my MSDN but have not been fruitfull

Connull
 
If I may so be so bold as to where I might obtain sample code for this. I
have looked through my MSDN but have not been fruitfull

For info on XslTransform just search MSDN for XslTransform :-)

To write the style sheet itself you'll need to get to grips with XSLT. This
site is always useful for XML pointers http://www.w3schools.com/xsl/

I've got a style sheet kicking about in work somewhere that I can dig out if
you want - might be useful as an example
James
 
James Mahoney said:
For info on XslTransform just search MSDN for XslTransform :-)

To write the style sheet itself you'll need to get to grips with XSLT. This
site is always useful for XML pointers http://www.w3schools.com/xsl/

I've got a style sheet kicking about in work somewhere that I can dig out if
you want - might be useful as an example
James

It would be appreciated. By the way, my xml document is viewable in Excel and I can also save the xml doc as xls. I unfortunately need the CSV as I need it in this format to import the data into another program. I thought there might be an easy way to use Excel's SaveAs option. Connull
 
I'm sure excel must have an import from XML option that will grab your XML
and add it to a work sheet. From there save as CSV should work.
Getting back to the XSL - my stylesheet would probably do more harm than
good. How are you getting your data out of the database - just as a dataset?

James
 
Back
Top