Skip to main content
Version: 4.17.3

XML to CSV component

The XML to CSV component allows you to convert files in the XML format into the CSV format.

Configuration

The XML to CSV component has the following configuration options:

Include header

Specify whether to include a header row in the CSV output.

Options

  • Yes (default)
  • No
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>food1</name>
<price>1</price>
<description>desc1</description>
</food>
<food>
<name>food2</name>
<price>2</price>
<description>desc2</description>
</food>
<food>
<name>food3</name>
<price>3</price>
<description>desc3</description>
</food>
</breakfast_menu>

Include index column

Specify whether to include an index column in the CSV output.

Options

  • Yes
  • No (default)
using index

When enabled, the index column will always be the first column and line numbers will be unquoted.

<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>food1</name>
<price>1</price>
<description>desc1</description>
</food>
<food>
<name>food2</name>
<price>2</price>
<description>desc2</description>
</food>
<food>
<name>food3</name>
<price>3</price>
<description>desc3</description>
</food>
</breakfast_menu>

Index column name

Specify the name of the index column. The default value is line.

note

Only available when Include index column is enabled.

Delimiter

Specify the character used to separate column values in the CSV output. The default value is , (comma).

Line separator

Specify the character used to separate lines in the CSV output.

Options

  • Line Feed (\n) (default)
  • Carriage Return (\r)
  • End Of Line (\r\n)

Order headers

Specify how the columns should be ordered in the CSV output (by name).

Options

  • Original (default)
  • Ascending
  • Descending
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>food1</name>
<price>1</price>
<description>desc1</description>
</food>
<food>
<name>food2</name>
<price>2</price>
<description>desc2</description>
</food>
<food>
<name>food3</name>
<price>3</price>
<description>desc3</description>
</food>
</breakfast_menu>

Quote fields

Specify which field types should be quoted in the CSV output.

Options

  • All fields (default)
  • Non integer fields
  • No fields
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>food1</name>
<price>1</price>
<description>desc1</description>
</food>
<food>
<name>food2</name>
<price>2</price>
<description>desc2</description>
</food>
<food>
<name>food3</name>
<price>3</price>
<description>desc3</description>
</food>
</breakfast_menu>

XPath expression

Specify an XPath expression to indicate which element is used for the conversion, read more about Using XML to CSV.

<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>food1</name>
<price>1</price>
<description>desc1</description>
</food>
<food>
<name>food2</name>
<price>2</price>
<description>desc2</description>
</food>
<food>
<name>food3</name>
<price>3</price>
<description>desc3</description>
</food>
<drink>
<name>drink1</name>
<price>1</price>
</drink>
<drink>
<name>drink2</name>
<price>2</price>
</drink>
</breakfast_menu>
Using Expresssions

Each expression type has a dedicated page on the Academy. You can find them under Guides > References:

Using XML to CSV

The XML should follow this structure:

<root>
<element>
<subElement>
<subSubElement></subSubElement>
</subElement>
</element>
</root>
processing depth

Processing is supported up to the subSubElement level.

<?xml version="1.0" encoding="UTF-8"?>    <!-- structure tags: -->
<items> <!-- root -->
<item> <!-- element -->
<firstName>Joe</firstName> <!-- subElement -->
<lastName>Foo</lastName> <!-- subElement -->
<age>21</age> <!-- subElement -->
<description> <!-- subElement -->
<title>Title</title> <!-- subSubElement -->
<body>Body</body> <!-- subSubElement -->
</description> <!-- subElement -->
</item> <!-- element -->
<item> <!-- element -->
<firstName>John</firstName> <!-- subElement -->
<lastName>Doe</lastName> <!-- subElement -->
<age>30</age> <!-- subElement -->
<description> <!-- subElement -->
<title>Title</title> <!-- subSubElement -->
<body>Body</body> <!-- subSubElement -->
</description> <!-- subElement -->
</item> <!-- element -->
</items> <!-- root -->
Key considerations
  • Only one type of element will be processed, the first one that is encountered.
  • Header names are based on the unique subElements and subSubElements.
    • SubSubElement names include their parent element, formatted as subElement_subSubElement.
  • Multiple subElements or subSubElements with the same name inside the same parent are ignored.
modify XML

Use the XSLT component or manually modify the XML to conform to the desired structure if:

  • Attributes need to be processed.
  • Multiple types of elements need to be processed.
  • Non-unique subElements or subSubElements within the same element need to be processed.
Last update on Feb 25, 2025