好吧,我已经不知所措了。这似乎是一件微不足道的事情,但一个小时后,我仍然无法让它工作。
我正试着从地图上获取时区列表
Campaign Monitor API
; 不幸的是,我需要使用的页面是用经典的ASP/Javascript编写的,所以我不能只使用API包装器。
var request = Server.CreateObject("Msxml2.ServerXMLHTTP");
request.open("GET", apiurl + "/User.GetTimezones?ApiKey=" + apikey, false);
request.send();
正确的XML将从服务器返回,如下所示:
<anyType d1p1:type="ArrayOfString" xmlns:d1p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://api.createsend.com/api/">
<string>(GMT) Casablanca</string>
<string>(GMT) Coordinated Universal Time</string>
<string>(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London</string>
<string>(GMT) Monrovia, Reykjavik</string>
<string>(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna</string>
<string>(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague</string>
<string>(GMT+01:00) Brussels, Copenhagen, Madrid, Paris</string>
(...and so on - I've truncated for the purpose of this question)
</anyType>
然后我将此XML加载到MSXML文档中:
var response = Server.CreateObject("Msxml2.DOMDocument.4.0");
response.async = false;
response.validateOnParse = false;
response.resolveExternals = false;
response.setProperty("SelectionNamespaces", "xmlns:d1p1='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://api.createsend.com/api/'");
response.setProperty("SelectionLanguage", "XPath");
if (response.load(request.responseXML))
{
// If I uncomment this, the XML is correctly written out
// Response.Write(response.xml);
var nodes = response.selectNodes("//string");
// No nodes are found, this is always zero
Response.Write(nodes.length);
for (var x = 0; x < nodes.length; x++)
{
// Do something with each time zone value here
}
}
有人能指出我做错了什么吗?非常感谢任何帮助!