Epicollect5 Project xml to json

by ParanoidAndroid77

HTML

<?xml version="1.0" encoding="utf-8" ?>
<ecml version="1">
    <model>//why id is the project name?
        <submission id="mirko_test_project" projectName="Mirko_Test_Project" allowDownloadEdits="false" versionNumber="2.1" />
        <uploadToServer>http://plus.epicollect.net/Mirko_Test_Project/upload</uploadToServer>
        <downloadFromServer>http://plus.epicollect.net/Mirko_Test_Project/download</downloadFromServer>
    </model>
    <form num="1" name="University" key="unique_form_id" main="true">
        <textarea ref="ecplus_University_ctrl14">
            <label>Multiline Text</label>
        </textarea>
        <input ref="unique_form_id" required="true" regex="^[a-zA-Z]+$" title="true">
        <label>Name</label>
        </input>
        <input ref="ecplus_University_ctrl2" default="29 Deeside Road">
        <label>Address</label>
        </input>
        <input ref="ecplus_University_ctrl12" integer="true" verify="true">
        <label>An integer field 1-9</label>
        </input>
        <input ref="ecplus_University_ctrl13" decimal="true" max="9" default="2.5">
        <label>Decimal Field</label>
        </input>
        <input ref="ecplus_University_ctrl3" default="Holland">
        <label>Country</label>
        </input>
        <input ref="ecplus_University_ctrl9" setdate="dd/MM/yyyy">
        <label>Created on this date</label>
        </input>
        <input ref="ecplus_University_ctrl10" settime="HH:mm:ss">
        <label>The time</label>
        </input>
        <radio ref="ecplus_University_ctrl11">
            <label>Test radio buttons</label>
            <item>
                <label>one</label>
                <value>1</value>
            </item>
            <item>
                <label>two</label>
                <value>2</value>
            </item>
            <item>
                <label>three</label>
                <value>3</value>
            </item>
        </radio>
        <select ref="ecplus_University_ctrl18">
           ...

JavaScript

{
    project: "Mirko_Test_Project",
    version: "5",
    uploadURL: "http://plus.epicollect.net/Mirko_Test_Project/upload",
    downloadURL: "http://plus.epicollect.net/Mirko_Test_Project/upload",
    forms: [{
        order: "1",
        name: "University",
        key: "unique_form_id"
        type: "main"
        inputs: [{
            ref: "unique_form_id",
            type: "text",
            required: "true",
            regex: "^[a-zA-Z]+$",
            title: "true",
            default: ""
        }, {
            ref: "ecplus_University_ctrl12",
            type: "integer",
            required: "false",
            regex: "",
            title: "false",
            default: "4"
        }]
    }, {
        order: "2",
        name: "Department",
        key: "Department_key"
        type: "main"
    }

    ]

}