我正在尝试使用 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 );
})});