Here’s a tool I developed that transforms CSV-data into XML-data based on a template.
You can use it to, for example:
- Create MadCap Flare snippet files
- Create topic files
- Create MadCap Flare target files
- Create MadCap Flare condition sets
- Create MadCap Flare variable sets
You can use it to convert any type of CSV-data into text files (e.g. HTML, XML, etc).
Converting CSV data to XML files using a template
To convert files, you need
- A CSV-data file. You can use any text editor or save your Excel spreadsheet as a CSV file.
- An XML-template file.
Set up the CSV data
- Ensure that the CSV file has headers, because the first line in the CSV does not get converted.
- Verify which type of separator the file has (comma, semicolon, or tab)
In the example file (data.csv), the data looks like this:
Heading;Paragraph Heading A;Paragraph A Heading B;Paragraph B Heading C;Paragraph C Heading D;Paragraph D Heading E;Paragraph E Heading F;Paragraph F
Set up the XML template
In the XML template, you add HTML comments wherever you want to insert data from a column in the CSV file.
- The index of the first column is 0 (zero).
In the example file (template.xml) I’ve inserted one column in the H1 and another one in the P-tag:
<html> <body> <h1><!----></h1> <p><!----></p> </body> </html>
Convert the CSV data to XML files
Use the following syntax to create files based on the examples above.
CSVtoXMLconverter.exe "data.csv" "template.xml" "" "0.htm" ";"
The CSVtoXMLconverter takes 5 arguments to run
- The source CSV-data, (e.g. “c:\data\CSVdata.csv”)
- The XML-template, (e.g. “c:\data\XMLtemplate.xml”)
- The destination folder (e.g. “C:\data\stuff”). If left blank, the files are created in the same folder as the .exe file.
- The file name column (e.g. “0.htm” will create .htm files using the data in the first column as the file name)
- The type of separator (e.g. “,” or “;”, or “tab”). If left blank, “;” is used.
Did you find this useful? Let me know!
Found a few bugs? Let me know! 🙂
Good luck and have fun converting!