Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)


About a year ago, I wrote an article that detailed how to use the ConvertRecord processor and Record Reader/Writer controller services to easily convert a CVS file into various formats (JSON, Avro, XML):

At the time, the CSV to XML conversion was done using a ScriptedRecordSetWriter. With the release of NiFi 1.7.0, the CSV to XML conversion can be done much more simply with the new XMLRecordSetWriter.


This tutorial was tested using the following environment and components:

  • Mac OS X 10.11.6
  • Apache NiFi 1.7.0

Convert CSV to XML

Support Files

Here is a template of the flow discussed in this tutorial:


Here is the CSV file used in the flow:


Note: Change the extension from .txt to .csv after downloading.

Demo Configuration

Import Template

Start NiFi. Import the provided template and add it to the canvas.

You should see the following flow:


Note: After importing the template, create or make sure the directory paths for the GetFile and PutFile processors exist, confirm users.csv is in the input directory and enable all Controller Services before running the flow:


Flow Highlights

Details of the original flow are covered in my previous HCC article, but here are the key changes made:

ConvertRecord - CSVtoXML (ConvertRecord Processor)

Record Reader is still set to "CSVReader" but Record Writer is now set to the new "XMLRecordSetWriter":


XMLRecordSetWriter Controller Service

Here are the properties for this controller service:


Besides the default values, Schema Access Strategy property is set to "Use 'Schema Name' Property", Schema Registry is set to AvroSchemaRegistry and Name of Root Tag is set to "record".

Flow Results

Running this updated flow now produces a flowfile with XML contents:



Hi Alim,

Your solution works fine for me except the xml file content is coming in one single line instead of blocks. Any idea why?


Help, I want to do a transformation from a flat file to a custom XML in nifi. Some example. The result should be like the picture



Community Manager

@JeanGuzman , As this is an older article, you would have a better chance of receiving a resolution by starting a new thread. This will also provide the opportunity to provide details specific to your environment that could aid others in providing a more accurate answer to your question. 

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.
Version history
Last update:
‎08-17-2019 07:07 AM
Updated by:
Top Kudoed Authors