我正在尝试使用Zoho Creator API获取一个包含记录的XML文件,这些记录可以在新的HTML文档中访问,并插入XML文件中的特定值。请参阅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>");我也在考虑使用Google Fusion Tables来做这件事。如果任何人有任何建议,从一个容易组织的外部数据库中提取非常简单的数据,请让我知道。
我也尝试过这个方法,但在某处读到,如果xml在另一个域上,它将不起作用
$(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 );
})}); 发布于 2012-12-27 04:15:43
首先,不要在公共论坛上发布你的authtoken。请用星号替换它。它非常敏感。
其次,视图似乎返回了正确的响应。我尝试查询视图并获得XML响应。我想您需要一些专家的建议来迭代XML响应
这里有一些帮助链接供您参考。
还有一种方法可以将View数据存储在JSON对象中。下面的示例URL
<script src="https://creatorexport.zoho.com/userName/appName/json/Agent_Roster_View/privateKey/variable=myData"></script>上面的脚本将View数据存储在一个JSON对象中。要为视图生成私钥,可以参考我在https://kbase.creator.zoho.com/views/how-to-generate-feed-url-for-views#json上的帖子
https://stackoverflow.com/questions/13825378
复制相似问题