Skip Links

Network World

  • Social Web 
  • Email 
  • Close

Turning spreadsheets into XML

Dr. Internet By Steve Blass , Network World , 01/26/2004
Steve Blass
Newsletter Signup
  • Share/Email
  • Tweet This
  • Comment
  • Print

What's the easiest way to convert data stored in comma-separated value files into XML format? We need to use the names in the header row of the CSV file for the XML element names and create a basic XML document containing <rows> filled with the named elements containing our data values.

You can find CSV-to-XML conversion programs with a simple Web search.

The easiest solution is to let somebody else do it. A free online conversion utility found in the Tools section at www.creativyst.com will transform files up to 250K bytes using a simple Web form.

Paste your CSV data into the form, and copy the XML results back using your browser. Kirk Evans describes how to convert CSV to XML using XSLT and the XPATH functions substring-before() and substring-after() to parse the rows and values on the weblogs.asp.net site (details here). You have to wrap the CSV data in an XML <root> tag to process the file with XSLT.

For converting large numbers of large CSV files, you will want a stand-alone desktop program, such as the CSV 2 XML Converter from www.goedeke.net, which lets you output multiple XML formats from existing CSV files.

  • Share/Email
  • Tweet This
  • Comment
  • Print
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a NetworkWorld account? Log in here. Register now for a free account.

Videos

rssRss Feed