Question

I am trying to use the Zoho Creator API to get an XML file with records that can be accessed within a new HTML document and have specific values from the XML file inserted. See code here in the jsfiddle http://jsfiddle.net/vm5m6/

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
     xmlhttp.open("GET","https://creator.zoho.com/api/xml/uownrealestate/view/Agent_Roster_View?    authtoken=***scope=creatorapi",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 
  document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("record");
for (i=0;i<x.length;i++)
 { 
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("value")[0].childNodes[0].nodeValue);
document.write("</td><td>");

}
document.write("</table>");

i was also considering using Google Fusion Tables to do this as well. If anyone has any suggestions for pulling very simple data from an easily organized external database please let me know.

I also tried this but read somewhere that it will not work if the xml is on another domain

 $(function() {
   var xml =     'https://creator.zoho.com/api/xml/uownrealestate/view/Agent_Roster_View?authtoken==creatorapi'
   $(xml).find("record").each(function() {
  var stateName = $(this).find("Agent_Name").text();

  alert("State: " + stateName );
   })});    
Was it helpful?

Solution

First, don't post your authtoken in a public Forum. Please replace it with asterisks. It's very sensitive.

Second, the View seems to return the response right. I tried to query the View and got the XML response. I guess you will need some experts' advice on iterating the XML response

There are some help links for your reference.

  1. https://forums.zoho.com/topic/unleash-your-zoho-creator-html-views-using-zcml
  2. https://github.com/srhyne/ZCML/

There is also a way to store the View data in a JSON object. Sample URL below

<script src="https://creatorexport.zoho.com/userName/appName/json/Agent_Roster_View/privateKey/variable=myData"></script>

The above script will store the View data in a JSON object. To generate the private key for Views, you can refer to my post at https://kbase.creator.zoho.com/views/how-to-generate-feed-url-for-views#json

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top