How to write the XML data into Rollbase Object

Posted by Sudhakar on 10-Feb-2014 12:38

Hi all,

How to read the xml data and write it into Rollbase Object.

Thanks,

Sudhakar

All Replies

Posted by sidury on 10-Feb-2014 14:47

Hello,

Can you please clarify your requirement?

Thanks.

Posted by Sudhakar on 10-Feb-2014 14:57

i need  to store data into Rollbase object from an XML file while we are  uploading the xml file..

Posted by sidury on 10-Feb-2014 15:03

Hello,

Please consider using "File Upload" field in Rollbase object.

Hope this helps.

Thanks.

Posted by Sudhakar on 11-Feb-2014 12:58

Hi Sidury,

my requirement is not only storing the xml file, i want to store the values from the XML file.

ex: consider some part of xml file is

<book id="bk105">

     <author>Corets, Eva</author>

     <title>The Sundered Grail</title>

     <genre>Fantasy</genre>

     <price>5.95</price>

     <publish_date>2001-09-10</publish_date>

     <description>The two daughters of Maeve, half-sisters,

     battle one another for control of England. Sequel to

     Oberon's Legacy.</description>

  </book>

i want to store the author,title,genre,price... as fields and Corets,Eva The Sundered grail,Fantasy,5.95.. as the field values in Rollbase object

Posted by Miguel Saez on 11-Feb-2014 13:22

Hi,

An idea could be when you create a new record uploading the xml file,  you could create an Object Script trigger with following code:

/**

In this example my RB object name is:test and xml_file the upload file

*/

var xml = rbv_api.getTextData("test", {!id}, "xml_file"); /* Move the content from xml file uploaded in a string var*/

var root = rbv_api.parseXML(xml);

author = root.getElementsByTagName('author').item(0).getFirstChild().getNodeValue(); /* Get the xml value of author */

title = root.getElementsByTagName('title').item(0).getFirstChild().getNodeValue();/* Get the xml value of title*/

/*** You should repeat in the same way for the rest of your field in the xml file ***/

rbv_api.setFieldValue("test",{!id},'author',author);  /** You can use this method to save the value in your RB fields**/

rbv_api.setFieldValue("test",{!id},'title',title);

Hope this help,

Miguel

Posted by Sudhakar on 11-Feb-2014 13:56

thank you [mention:560ea9bef1ac488b986d6da8f043b779:e9ed411860ed4f2ba0265705b8793d05] ,

Perfectly working.

This thread is closed