Automation Excel MadCap Flare Technical communication

Convert CSV-data to XML-files

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).

Click here to download the converter along with some sample CSV data!CSV to XML converter

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 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:


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

  1. The source CSV-data, (e.g. “c:dataCSVdata.csv”)
  2. The XML-template, (e.g. “c:dataXMLtemplate.xml”)
  3. The destination folder (e.g. “C:datastuff”). If left blank, the files are created in the same folder as the .exe file.
  4. The file name column (e.g. “0.htm” will create .htm files using the data in the first column as the file name)
  5. The type of separator (e.g. “,” or “;”, or “tab”). If left blank, “;” is used.

 Your turn!

Did you find this useful? Let me know!

Found a few bugs? Let me know! 🙂

Good luck and have fun converting!

Leave a Reply

Your email address will not be published. Required fields are marked *