0 Replies Latest reply on May 22, 2015 3:48 PM by szarekar

    Add child attributes to elements (convert csv to xml using Apache camel)


      I was able to convert csv to xml using code My question is what changes are needed in EmployeeDTO.java to get the expected output below -( I want the child attributes to be displayed)

      MY EmployeeDTO.java



      @CsvRecord(separator = ",", skipFirstLine = true)

      public class EmployeeDTO implements Serializable{


            @DataField(pos = 1)

            private int employeeId;


            @DataField(pos = 2)

            private String firstName;


            @DataField(pos = 3)

            private String lastName;


            @DataField(pos = 4)

            private String role;



      And camel-context.xml is

      <bean id="bindyDataformat" class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
      <constructor-arg value="com.fusesource.sample.dto" />


      <camelContext xmlns="http://camel.apache.org/schema/spring">
      <jmxAgent id="agent" disabled="false" />
      <from uri="file:src/data?noop=true" />
      <unmarshal ref="bindyDataformat" />
      <to uri="file://TESTOUT?fileName=sampada.xml"/>


      Actual Output xml file

      <?xml version='1.0' encoding='UTF-8'?>
      <role>Java Lead</role>


      <Employees id="" total="">
      <employeeId id="" reportGroup="">23445</employeeId>
      <role>Java Lead</role>