Connecting Tech Pros Worldwide Help | Site Map

Convert xml to csv

Connull
Guest
 
Posts: n/a
#1: Nov 22 '05
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
James Mahoney
Guest
 
Posts: n/a
#2: Nov 22 '05

re: Convert xml to csv


> I have extracted data from a SQL database and need to convert it to a csv. I[color=blue]
> 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.
>[/color]

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
Connull
Guest
 
Posts: n/a
#3: Nov 22 '05

re: Convert xml to csv




"James Mahoney" wrote:
[color=blue][color=green]
> > 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.
> >[/color]
>
> 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[/color]

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
James Mahoney
Guest
 
Posts: n/a
#4: Nov 22 '05

re: Convert xml to csv


[color=blue][color=green]
> > 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[/color]
>
> 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
>[/color]

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



Connull
Guest
 
Posts: n/a
#5: Nov 22 '05

re: Convert xml to csv




"James Mahoney" wrote:
[color=blue]
>[color=green][color=darkred]
> > > 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[/color]
> >
> > 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
> >[/color]
>
> 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.[/color]
Connull[color=blue]
>[/color]
James Mahoney
Guest
 
Posts: n/a
#6: Nov 22 '05

re: Convert xml to csv


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

"Connull" wrote:
[color=blue]
>
>
> "James Mahoney" wrote:
>[color=green]
> >[color=darkred]
> > > > 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
> > >[/color]
> >
> > 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.[/color]
> Connull[color=green]
> >[/color][/color]
Closed Thread


Similar .NET Framework bytes