Skip to main content
Version: 4.16.0

CSV to XML component

The CSV to XML component offers direct conversion from CSV format to XML format, useful for scenarios such as receiving CSV files from an FTP component.

Configuration

The CSV to XML component has the following configuration options:

Delimiter

Sets the delimiter character for the fields of a CSV line. The default value is ,.

Tab Separated Values (TSV)

This component also supports Tab Seperated Values (TSV), just specify \t as delimiter.

Use header

Specifies whether to use the first line of the CSV to function as header values. If the first line of the CSV doesn't contain header values, set this to option to no.

Invalid XML characters will be filtered out of the CSV headers according to the following rules. They can't:

  • Begin with a digit.
  • Contain special characters other than the period, hyphen, underscore and colon.
  • Start with special characters like hypens or periods.
  • Start with any variation of 'xml'.
duplicate headers

The CSV can't contain duplicate headers. If your CSV contains duplicate headers, you can resolve this by setting the Use header option to no. If you still want to use headers you can use the Replace component to change the CSV headers.

XML encoding

Specifies the encoding for the resulting XML. The default value is UTF-8.

Using CSV to XML

Before performing the CSV to XML transformation, it's crucial to verify the encoding of the CSV file. The Content-Type of the CSV file must be text-plain with the charset set to UTF-8 for the transformation to work correctly. You can use the Encoder component to adjust the encoding of a file if necessary.

Content-Type header

Setting a Content-Type header with value text-plain;charset=utf-8 using a SetHeaders component can resolve issues with improper transformations in some cases.

CSV with headers

The CSV to XML component is configured with delimiter set to , and use header set to yes. The XML encoding is left to its default value.

Given the CSV input:

first-name,last-name,age
Joe,Foo,21
John,Doe,30

The CSV to XML component will produce the following output:

<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<first-name>Joe</first-name>
<age>21</age>
<last-name>Foo</last-name>
</item>
<item>
<first-name>John</first-name>
<age>30</age>
<last-name>Doe</last-name>
</item>
</items>

CSV without headers

The CSV to XML component is configured with delimiter set to ; and use header set to no. The XML encoding is left to its default value.

Given the CSV input:

Joe;Foo;21
John;Doe;30

The CSV to XML component will produce the following output:

<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<string>Joe</string>
<string>Foo</string>
<string>21</string>
</item>
<item>
<string>John</string>
<string>Doe</string>
<string>30</string>
</item>
</items>
Last update on May 15, 2024