Custom Form Builder to Export XML into ODK Aggregate Server

Hi, I have a web application that have pre-defined set of questions as shown in the image below. A user is supposed to select a subset of the questions that he wants then click "Export Assessment". An XML should be created which will be imported into ODK Aggregate server which then becomes a Form which users in the field can get using ODK collect.

So far when a user clicks the Export I can only manage to create a json like below. Could someone point me to an easier way to end up with an ODK compliant form, thanks.
[
{refField: null, label: "How many minutes does it take you to reach the nearest hospital from home?", hint: null, labelField: null, hintField: null,labelField: null, ref: "/data/group_ca7gs53/minutes_walk_hosp"}
{refField: null, label: "What mode of transport is your previous answer based on?", hint: null, labelField: null, hintField: null,labelField: null, ref: "/data/group_ca7gs53/mode_of_transport_prev_answe_0"}
{refField: null, label: "Specify other", hint: null, labelField: null, hintField: null,ref: "/data/group_ca7gs53/Specify_other_011"}
{refField: null, label: "How far is the river/dam from your house?", hint: null, labelField: null, hintField: null,ref: "/data/group_ca7gs53/minutes_walk_hosp"}
]

1 Like