LiveCycle Designer - Rest API and parse XML

274 views
Skip to first unread message

Mattias Harneman

unread,
Mar 19, 2015, 11:45:38 AM3/19/15
to live...@googlegroups.com
Hi everyone! 
A total noob in LiveCycle Designer.

I'm trying to get data from a Rest api and the returned data is in XML which I would like to parse.
Having trouble in JavaScript to connect to the API. As I understand XMLHttpRequest does not work in Designer.

I'm connecting to the API when you do exit* on a text field and want to fill some data in another field, so no submit action or so.

So I tried the Get-function in FormCalc instead, and then I get the data. But I'm unable to parse it in any good way in FormCalc.

So what to do? Can I connect to a Rest API in JavaScript or am I stuck with FormCalc and if so, how do I parse XML.
The FormCalc code looks something like this:



and the XML, or just plain string I guess, looks like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames>
   
<totalResultsCount>1</totalResultsCount>
   
<code>
       
<postalcode>118 62</postalcode>
       
<name>Stockholm</name>
       
<countryCode>SE</countryCode>
       
<lat>59.33258</lat>
       
<lng>18.0649</lng>
       
<adminCode1>AB</adminCode1>
       
<adminName1>Stockholm</adminName1>
       
<adminCode2>0180</adminCode2>
       
<adminName2>Stockholm</adminName2>
       
<adminCode3/>
       
<adminName3/>
   
</code>
</geonames>


I want the totalResultsCount and I want the name, that's it :)

Nithyanandam Dharmadass

unread,
Mar 22, 2015, 6:58:12 AM3/22/15
to No name
You are almost there. Just store the REST result into a text field (make it hidden).

You may further call a JS function to parse the result.

someHiddenTextField.rawValue = Get(url); // this line is in FormCalc
someJSFunction()

Next, write a JS function and process the results..

Regards,
Nith



--
You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to livecycle+...@googlegroups.com.
To post to this group, send email to live...@googlegroups.com.
Visit this group at http://groups.google.com/group/livecycle.
For more options, visit https://groups.google.com/d/optout.

Mattias Harneman

unread,
Apr 1, 2015, 11:30:31 AM4/1/15
to live...@googlegroups.com
Hi Nith!

Sorry, didn't see your answer there. Yes, I solved it by using the FormCalc Get() to receive the data from the REST service and then stored it in a hidden field and used initiate on that field and then parsed it in XML.
Thanks for the reply anyway.

/Best regards Mattias
Reply all
Reply to author
Forward
0 new messages