XML to CSV Converter
This adapter converts an XML file into a CSV file.
Properties
Operation | Defines the operation executed by the adapter. Possible values:
|
Parameters
Adapter | Main adapter class (do not change!) Possible values: de.softproject.integration.adapter.xml2csv.XML2CSVAdapter: Main class (default) |
headerInOutput | Required. Defines if there is a header in the CSV file to be created. Possible values: |
delimiter | Required. Defines the delimiter in the CSV file to be created. Possible values: Any delimiter, e.g. |
lineEnd | Required. Defines the character that marks the end of line in the CSV file to be created. Possible values: Character for the end of line, e.g. |
quotechar | Defines the quotes for elements within the CSV file to be created. Possible values:
|
escapechar | Defines the character that escapes certain characters that would otherwise be interpreted as control characters. Possible values:
|
encoding | Defines the character encoding for the operation. Possible values:
|
Status values
1 | The operation was executed successfully. |
-1 | The operation could not be executed. |
Input
The adapter expects the following input structure:
Input Structure
<?xml version="1.0" encoding="UTF-8"?>
<Csv>
<Header>
<Column name="columnName1" />
<Column name="columnName2" />
<Column ...
</Header>
<Records>
<Record>
<Column name="columnName1">value1</Column>
<Column name="columnName2">value2</Column>
<Column ...
</Record>
<Record>
<Column name="columnName1">value1</Column>
<Column name="columnName2">value2</Column>
<Column ...
</Record>
<Record ...
</Records>
</Csv>
If the parameter headerInOutput
is set to true
, a header is created in the output CSV file. The columns names are defined with the name
attribute within the Header/Column
element. As many columns are created as there are name
attributes.
If the parameter headerInOutput
is set to false
, no header is created in the output CSV file. The number of columns created is the maximum number of Column
elements within a Record
element.
Each entry must be contained in a Record
element. If a header is defined, the values are assigned to the column with the corresponding name
.
Output
The adapter outputs a CSV document with the structure that is defined in the input document.
Example
Example Input XML to CSV Converter
<?xml version="1.0" encoding="UTF-8"?>
<Csv>
<Header>
<Column name="Monday" />
<Column name="Tuesday" />
<Column name="Wednesday" />
</Header>
<Records>
<Record>
<Column name="Monday">First day</Column>
<Column name="Tuesday">Second day</Column>
</Record>
<Record>
<Column name="Monday">First day</Column>
<Column name="Tuesday">Second day</Column>
<Column name="Wednesday">Third day</Column>
</Record>
</Records>
</Csv>
The adapter parameters are set as follows:
headerInOutput
:true
delimiter
:,
encoding
:UTF-8
The above input leads to the following output:
Example Output XML to CSV Converter
Monday,Tuesday,Wednesday
First day,Second day,
First day,Second day,Third day