Hi guys,
I am developing an application which I am attempting to integrate / sync with Saasu using the getUrl action, however I am having trouble transforming the data into zoho where null values are present. I am new to Zoho and xml and have managed to get single GET and POST requests working, but I am having trouble with GET list requests.
I have been searching the help info and forums hoping to find a discussion that solves my problem but have not come across anything that discusses this problem as yet.
Below is an example responseText excerpt from Saasu for a GET contactList request:
<?xml version="1.0" encoding="utf-8"?>
<contactListResponse>
<contactList>
<contactListItem>
<contactUid>6499716</contactUid>
<utcFirstCreated>2013-02-17T23:08:47</utcFirstCreated>
<utcLastModified>2013-02-20T04:35:22</utcLastModified>
<lastUpdatedUid>AAAAACG0s+g=</lastUpdatedUid>
<givenName>jenny</givenName>
<familyName>biggs</familyName>
<emailAddress>
jenny.biggs@something.com</emailAddress>
<websiteUrl>www.something.com</websiteUrl>
<isActive>true</isActive>
<mainPhone>(07) 4786 4234</mainPhone>
<homePhone>(07) 4728 1076</homePhone>
<mobilePhone>0418980184</mobilePhone>
<otherPhone>(07) 4745 7499</otherPhone>
</contactListItem>
<contactListItem>
<contactUid>6499799</contactUid>
<utcFirstCreated>2013-02-19T23:08:47</utcFirstCreated>
<utcLastModified>2013-02-20T04:35:22</utcLastModified>
<lastUpdatedUid>AAAAACG5s+f=</lastUpdatedUid>
<givenName>jim</givenName>
<familyName>brown</familyName>
<emailAddress />
<websiteUrl />
<isActive>true</isActive>
<mainPhone />
<homePhone />
<mobilePhone />
<otherPhone />
</contactListItem>
<contactListItem>
<contactUid>6499828</contactUid>
<utcFirstCreated>2013-02-18T23:08:47</utcFirstCreated>
<utcLastModified>2013-02-20T04:35:22</utcLastModified>
<lastUpdatedUid>AAAAAKG0l+w=</lastUpdatedUid>
<givenName>john</givenName>
<familyName>smith</familyName>
<emailAddress />
<websiteUrl>www.mywebsite.com</websiteUrl>
<isActive>true</isActive>
<mainPhone>(07) 4728 4234</mainPhone>
<homePhone />
<mobilePhone>0419885184</mobilePhone>
<otherPhone />
</contactListItem>
</contactList>
</contactListResponse>
My main problem is when I use the executeXPath command on the various response nodes, I get a full list of values for required fields (e.g. contactUid) but an incomplete list where null values exist for non-required fields (e.g. websiteUrl). See example below:
contactUidList = textResponse.executeXPath("/contactListResponse/contactList/contactListItem/contactUid/text()").toList("-|-"); produces the following list for the responseText above:
Index Value
0 6499716
1 6499799
2 6499828
where as:
websiteUrlList = responseText.executeXPath("/contactListResponse/contactList/contactListItem/websiteUrl/text()").toList("-|-"); produces the following list for the response above:
Index Value
From the lists above, Index 1 for contactUidList should align with a null value for websiteUrl, however Index 1 for websiteUrlList contains the value that should be applied against contactUidList Index 2.
Due to the way the executeXPath omits null values within the xml response, I end up with mismatching list index numbers and obtaining different list lengths for the various contact list fields. This then prevents me from allocating data in correct row order to the relevant zoho form.
Does anyone have any suggestions on an alternate approach to handling this reponse in order to allocate each of the response data values (incl null) to the corresponding (correct) row in the zoho database?
Thanks,
Brendan.