OK、私は私の知恵の終わりにいます。これは完全に些細なことのように思えますが、1時間経っても、それを機能させることはできません。
キャンペーンモニター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
}
}
コメントからわかるように、問題は、私が何をしても、それらの「文字列」ノードと一致しないように見えることです。ASP / Javascriptに関してはかなり錆びています-名前空間と関係があるのではないかと思います(過去にこれに問題があったことは知っています)が、何が原因かわかりません。
誰かが私が間違っていることを指摘できますか?どんな助けでも大歓迎です!