How to Import XML data to existing form

Hi Tino Kreutzer,

I am having problems importing XML data to existing form in https://kc.kobotoolbox.org.

Am able to import CSV data to exixsting form using below code:

var client = new RestClient("[https://kc.kobotoolbox.org/api/v1/forms/{pk}/csv_import](https://kc.kobotoolbox.org/api/v1/forms/%7Bpk%7D/csv_import)"); client.Authenticator = new HttpBasicAuthenticator("user_name", "password"); client.AddDefaultUrlSegment("pk", "35545"); string file_path = Server.MapPath("~/form1.csv"); var request = new RestRequest(Method.POST); request.AddFile("csv_file", file_path); IRestResponse response = client.Execute(request);

I want to achieve the save results but using XML instead of CSV.

When I tried to download data from https://kc.kobotoolbox.org I couldn't find XML option but XLS,CSV,ZIP,KML and Excel Analyser only. So its hard for me to get the correct format needed to import XML data.

1. Please provide for the the correct xml format needed to import data from xml to existing form
2. Please using the above code, edit it where necessary so that i could reuse it to import xml instead of csv.

For simplicity, I have attached a sample CSV data that you can use to come up with XML format.

Thanks in advance.
Jose

test.csv (292 Bytes)

Hi,

I’ve not tried this yet, but it seem logical that the upload format needs to be in the same format as the download. So if you download some existing data through the API by adding ?format=xml to the regular URL, you get the data in XML format.

I hope it works.

Gerard

···

On Wednesday, 27 January 2016 13:39:00 UTC+1, Joseph Luketelo wrote:

Hi Tino Kreutzer,

I am having problems importing XML data to existing form in https://kc.kobotoolbox.org.

Am able to import CSV data to exixsting form using below code:

var client = new RestClient("[https://kc.kobotoolbox.org/api/v1/forms/{pk}/csv_import](https://kc.kobotoolbox.org/api/v1/forms/%7Bpk%7D/csv_import)"); client.Authenticator = new HttpBasicAuthenticator("user_name", "password"); client.AddDefaultUrlSegment("pk", "35545"); string file_path = Server.MapPath("~/form1.csv"); var request = new RestRequest(Method.POST); request.AddFile("csv_file", file_path); IRestResponse response = client.Execute(request);

I want to achieve the save results but using XML instead of CSV.


When I tried to download data from [https://kc.kobotoolbox.org](https://kc.kobotoolbox.org) I couldn't find XML option but XLS,CSV,ZIP,KML and Excel Analyser only. So its hard for me to get the correct format needed to import XML data.


1. Please provide for the the correct xml format needed to import data from xml to existing form
2. Please using the above code, edit it where necessary so that i could reuse it to import xml instead of csv.


For simplicity, I have attached a sample CSV data that you can use to come up with XML format.


Thanks in advance.
Jose


1 Like

Hi Gerard & Joseph,

The format for the form XML file is different from XML data submitted back to the server. The submitted XML uses the same root instance name and question names of course. To see what submittable data looks like just use Collect to create dummy data and check out the XML files in the /odk/instances/ folder. In Enketo, if you collect data offline, open the queue and use the new Export feature to download the XML instances.

To be clear, XML is used for the form definition and to submit data back to the server, but there is no direct XML data download option available. You can however download the raw instances back to your computer using the /briefcase API endpoint.

Best,
Tino

···

On Sun, May 22, 2016 at 10:46 PM Gerard Schut gerard...@gmail.com wrote:

Hi,

I’ve not tried this yet, but it seem logical that the upload format needs to be in the same format as the download. So if you download some existing data through the API by adding ?format=xml to the regular URL, you get the data in XML format.

I hope it works.

Gerard

On Wednesday, 27 January 2016 13:39:00 UTC+1, Joseph Luketelo wrote:

Hi Tino Kreutzer,

I am having problems importing XML data to existing form in https://kc.kobotoolbox.org.

Am able to import CSV data to exixsting form using below code:

var client = new RestClient("[https://kc.kobotoolbox.org/api/v1/forms/{pk}/csv_import](https://kc.kobotoolbox.org/api/v1/forms/%7Bpk%7D/csv_import)"); client.Authenticator = new HttpBasicAuthenticator("user_name", "password"); client.AddDefaultUrlSegment("pk", "35545"); string file_path = Server.MapPath("~/form1.csv"); var request = new RestRequest(Method.POST); request.AddFile("csv_file", file_path); IRestResponse response = client.Execute(request);

I want to achieve the save results but using XML instead of CSV.


When I tried to download data from [https://kc.kobotoolbox.org](https://kc.kobotoolbox.org) I couldn't find XML option but XLS,CSV,ZIP,KML and Excel Analyser only. So its hard for me to get the correct format needed to import XML data.


1. Please provide for the the correct xml format needed to import data from xml to existing form
2. Please using the above code, edit it where necessary so that i could reuse it to import xml instead of csv.


For simplicity, I have attached a sample CSV data that you can use to come up with XML format.


Thanks in advance.
Jose


–

You received this message because you are subscribed to the Google Groups “Kobo Users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to kobo-users+...@googlegroups.com.

To post to this group, send email to kobo-...@googlegroups.com.

Visit this group at https://groups.google.com/group/kobo-users.

For more options, visit https://groups.google.com/d/optout.

1 Like