Americas

  • United States

Turning spreadsheets into XML

Opinion
Jan 26, 20042 mins
Enterprise ApplicationsProgramming Languages

* Dr. Internet columnist Steve Blass helps a reader convert spreadsheets into XML

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 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 http://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 (https://weblogs.asp.net/KAEvans/posts/5780.aspx). You have to wrap the CSV data in an XML 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 http://www.goedeke.net, which lets you output multiple XML formats from existing CSV files.