Skip to main content
Version: 4.10.1

CSV to XML component

The CSV to XML component provides a direct conversion from the CSV format to XML format. This component could, for example, be used when you receive CSV files from a FTP component.

Configuration

The CSV to XML component has the following configuration options:

PropertyDefaultDescription
Delimiter,Specifies the delimiter character for the fields of a CSV line.
Use headeryesIf you want to use the first line of CSV to function as header values. If the first line of the CSV don't contain header values, set this to option to no.
XML encodingUTF-8Specifies the encoding for the resulting XML.

Remarks

  • The CSV can't contain duplicate headers. If your CSV contains duplicate headers, this can be solved by setting the Use header to no. If you still want to use headers you can use another component like the Replace Component to change the headers of the CSV.
  • This component also supports Tab Seperated Values (TSV). Specify \t as Delimiter if you need this feature.
  • Invalid XML characters will be filtered out of the CSV headers. Following rules apply:
    • Names can't begin with a digit
    • Names can't contain special characters other than the period, hyphen, underscore, and colon
    • Names can't start with special characters like hypens or periods
    • Names can't start with any variation of 'xml'

Examples

There are two kinds of XML output. This depends on the Use header option.

CSV with headers

Let's assume the CSV to XML component is configured as with the following settings:

PropertyValue
Delimiter,
Use headeryes
XML encodingUTF-8

When given the CSV input...

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

...The CSV to XML component will yield 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

Let's assume the CSV to XML component is configured as with the following settings:

PropertyValue
Delimiter,
Use headerno
XML encodingUTF-8

When given the CSV input... (without headers)

Joe,Foo,21 John,Doe,30

...The CSV to XML component will yield 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>