12 Replies Latest reply on Nov 25, 2019 11:26 PM by inuser516659

    ICRT Sample - Reading and Writing - XML to Delimited CSV or JSON and Vice Versa.

    Casey Clayton Seasoned Veteran

      This post is meant to both specifically answer some recent discussion posts on the Community about the process of taking an XML and writing to a CSV. 


      I have attached a Word Doc walkthrough with a Quick Start, specific to the use case of turning a "multi-level" XML input to a "flattened" CSV file.


      I've attached the sample processes and data to this post as well


      Topics: File Connection, XML, JSON, CSV, Delimited Content Writer.


      File Connection, Event Target Tab:  Define a “Delimited Content Writer”

      In “File Exists” you can choose Append, but make sure that if you do Append, also select “Skip Headers”



      You will need a Process Object defined that only has “Simple Types”.  That’s the key of the Serialization Task, in the Object you are assigning to the “Custom Objects”, there can be no fields of “Reference” type.


      Here is my sample Hierarchical Process Object (just the top level)

      Here is the "Flattened" Order, used to hold the data for CSV output


      In the Process

      I use the “Applies To” here because I want this process to be called by parent process that uses the “Run on each object in List” property.  Ultimately, all you need to make this work is a “Flat” process object, so don’t worry if your use case calls for a different “Applies To” or runs on the “Cloud Server” as opposed to the Secure Agent like mine does (the scenario I built this for originally was for an XML flat file, but this pattern will work on a Process Object returned by a Web Service Connector just the same).




      On the fields Tab

      1. Type of Object > Process Objects > *Object Name*

      2. Type of Object>*File Connection Name*>Delimited Content Serialization Taks



      1.  Assignment Step

      Map” from your Native XML structure to this Flat Process Object.






      2.  Assignment Step

      Assign the minimum fields for a Serialization Task

      thisCSVtask >Custom Object   -- (flat) Object or Object List of your choice

      thisCSVtask >File Name – filename of choice



      3.  Service Call Step

      Service Call to your File Connection > CSVWriter.

      Input serializationTask --  Delimited Content Serialization Task Temporary Field used in step 2