Hi all,
OK, I'm at my wits end. This seems like it should be a completely trivial thing to do, yet after an hour I still just cannot make it work.
I'm trying to get a list of time zones from the Campaign Monitor API; unfortunately the page I need to do this in is written in classic ASP/Javascript so I can't just use the API wrapper.
I'm making the request like this:
var request = Server.CreateObject("Msxml2.ServerXMLHTTP");
request.open("GET", apiurl + "/User.GetTimezones?ApiKey=" + apikey, false);
request.send();
The correct XML is coming back from the server, as follows:
<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>
Then I am loading this XML into an MSXML document:
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
}
}
The problem, as you can see from the comments, is that I can't seem to match those 'string' nodes no matter what I do. I'm pretty rusty when it comes to ASP/Javascript - I suspect it's something do do with the namespaces (I know I had problems with this in the past), but I'm not sure what.
Can anyone point out what I'm doing wrong? Any help much appreciated!