Import a xml file into a collection

299 views
Skip to first unread message

maybeg...@gmail.com

unread,
Apr 25, 2014, 2:20:10 PM4/25/14
to suppor...@runmyprocess.com
Hi.

I'm trying to import a xml file into a collection, but I'm not sure how to use the correct code here.

First, I upload the xml file into the system via the file tab in a determinated project.
I've already created a collection, but I'm not sure how to import determinated columns from the xml file into this collection.

I know I need to use:
${import_objects(file_id, collection-name [, separator [, drop]] )}

My questions are:
1.In which section should I use this code to import the xml into de collection in live mode?
2. how could I choose determinated columns?, because I don´t want to use all the info of my xml file, only certain columns.

Thanks in advance
my xml file.PNG

Sabine El Rassy

unread,
Apr 28, 2014, 6:08:12 AM4/28/14
to RunMyProcess Support Forum
Hello,

The function ${import_objects(file_id, collection-name [, separator [, drop]] )} is only available for CSV files.
For your XML file, supposing that your file content is :
<entry>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Dont forget me this weekend!</body>
</note>
<note>
<to>John</to>
<from>Ronald</from>
<heading>Reminder</heading>
<body>Buy </body>
</note>
</entry>


You can try to do as follow:

<#function get_array my_father my_son>
<#if my_father?is_hash>
<#if my_father[my_son]?exists>
<#if my_father[my_son]?is_sequence>
<#assign my_array = my_father[my_son]>
<#else>
<#assign my_array = [my_father[my_son]?eval]>
</#if>
<#else>
<#assign my_array = []>
</#if>
<#else>
<#assign my_array = []>
</#if>
<#return my_array>
</#function>
<#assign my_xml= file_content(your_file_id,'none')>
<#assign my_json = load(my_xml,"XML")>
${get_array(my_json.entry,"note")}

This will transform your XML to an array of json. Then you can iterate over your json as you wish.

Regards,


Sabine EL RASSY

Customer Solutions Engineer

maybeg...@gmail.com

unread,
Apr 28, 2014, 1:33:06 PM4/28/14
to suppor...@runmyprocess.com, maybeg...@gmail.com
Hi Sabine El Rassy.

Thanks for your answer. So in order to import my XML spreadsheet file(an excel file) to a collection I need to transform this in a array of Json and then iterate it?

I don't know if is there a simpler approach , I mean if I can choose columns from an excel file, and put the info related with each column inside the collection.


I'm not sure if I made myself understood.
Thanks in advance.
att: nes

Sabine El Rassy

unread,
Apr 29, 2014, 4:37:26 AM4/29/14
to RunMyProcess Support Forum, Nesgeek Cepeda
Hello,

The import_objects accepts CSV files only, so it won't work with any other type of files.
So you need to iterate over your json and add only columns that you need into your collection.


Regards

maybeg...@gmail.com

unread,
Apr 30, 2014, 3:11:56 PM4/30/14
to suppor...@runmyprocess.com, maybeg...@gmail.com
Hi Sabine,


In Order to use the tools that are offered by RMP, I converted the xml spreadsheet file into a .CSV file.

So I need to create a JS widget in the collection WI with this code, right?:

${import_objects(file_id, collection-name [, separator [, drop]] )}


Other question, how can I choose determinated columns to save in my collection database?

Thanks you.

att:
nes

Sabine El Rassy

unread,
May 5, 2014, 5:54:25 AM5/5/14
to RunMyProcess Support Forum, Nesgeek Cepeda
Hello,

${import_objects(file_id, collection-name [, separator [, drop]] )} is a freemarker function executed on server side so you cannot use it directly in JS. You need to create a composite API that executes this code for you.
This function will import everything you have in your CSV file. The function does not handle column customization.

For more information  on composite API, please click on the following link.

Regards
Sabine

maybeg...@gmail.com

unread,
May 5, 2014, 5:15:52 PM5/5/14
to suppor...@runmyprocess.com, maybeg...@gmail.com
Thanks Sabine!!!

I'll make some test and I'll notify you.

Att:
nes

maybeg...@gmail.com

unread,
May 15, 2014, 5:09:34 PM5/15/14
to suppor...@runmyprocess.com, maybeg...@gmail.com
Hi

I made some test, but I don't know how to make it working.

I mean, my approach is :
Import a Csv file into a collection ( the simplest way ).

My question is:
At the time I create the composite api, where do I need to configure it to "trigger" and adding the related info?

I need to make this because I'm using an autocomple widge, and it's required to show all the info to the final user, using the info stored in this collection.


I attached some images related to this issue.


att:
nes

1 composite API.PNG
2 script.PNG

maybeg...@gmail.com

unread,
May 21, 2014, 11:55:05 AM5/21/14
to suppor...@runmyprocess.com, maybeg...@gmail.com
I found another approach thanks to sushma padidela.

The .xml file was converted into .csv file, and then uploaded via a upload widget.
Next with a process ( server side) I can import this .csv file into a collection.

But I have other issue when I tried to show the info in the WI report.
I posted it.

maybeg...@gmail.com

unread,
May 22, 2014, 10:35:53 AM5/22/14
to suppor...@runmyprocess.com, maybeg...@gmail.com
It's solved.

I can give you a complete feedback if you want a more specific explanation.

For purposes to learning.
Thanks.


Sabine El Rassy

unread,
May 23, 2014, 5:03:09 AM5/23/14
to RunMyProcess Support Forum, Nesgeek Cepeda
Hello,

Glad that you've managed to solve your problem. Yes please do share your experience!

Regards

Sabine EL RASSY

Customer Solutions Engineer

     
Fujitsu RunMyProcess user? Please add a review on GoogleApps Marketplace

Afin de contribuer au respect de l'environnement, merci de n'imprimer ce message qu'en cas de nécessité.
Be environmentally friendly: do not print this email unless it is entirely necessary.




--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/4a6f5751-d7cf-4b93-8ca3-92216b7ae18a%40runmyprocess.com.

Reply all
Reply to author
Forward
0 new messages