Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 520009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:06:01+00:00 2026-05-13T08:06:01+00:00

OK, I’m at my wits end. This seems like it should be a completely

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:06:01+00:00Added an answer on May 13, 2026 at 8:06 am

    You cannot override the default namespace used by XPath. In MSXML the XPath default namespace is always the “no name” namespace. However there is no need for the set of aliases used in the SelectionNamespaces property to match those of the document (although of course it makes sense where possible to use the same ones).

    Define your set of namespaces like this:-

    var ns = "xmlns:a='http://api.createsend.com/api/' "
           + "xmlns:d1p1='http://www.w3.org/2001/XMLSchema-instance'"
    response.setProperty("SelectionNamespaces", ns);
    

    Now you can select all the string elements with:-

    var nodes = response.selectNodes("//a:string");
    

    This is how I would code this as a whole:-

    var response = Server.CreateObject("MSXML2.DOMDocument.3.0");  // or use 6.0 but not 4.0
    response.async = false;
    response.validateOnParse = false;
    response.resolveExternals = false;
    
    
    response.setProperty("ServerHTTPRequest", true); 
    
    if (response.load(apiurl + "/User.GetTimezones?ApiKey=" + apikey)) 
    {
    
        var ns = "xmlns:a='http://api.createsend.com/api/' "
               + "xmlns:d1p1='http://www.w3.org/2001/XMLSchema-instance'"
        response.setProperty("SelectionNamespaces", ns);
    
        response.setProperty("SelectionLanguage", "XPath");  // remove for 4.0 or above is default
    
        var nodes = response.selectNodes("//a:string");
    
        Response.Write(nodes.length);
    
        for (var x = 0; x < nodes.length; x++) 
        {
            // Do something with each time zone value here
        }
    }
    

    Notes:-

    • For a GET request there is no need to use a separate ServerXMLHttp object, you can instruct the DOMDocument to use ServerXMLHttp internally when by enabling the ServerHTTPRequest property. (BTW, your code seems to be reduntantly streaming the DOMDocument exposed in by the ResponseXML property into a new DOMDocument).
    • I prefer to use the 3.0 version of MSXML since that is guaranteed to be present on supported platforms. If not then I would install 6.0 and use that.
    • Specifying the SelectionLanguage to be XPath on 4.0 or above is redundant, its the default selection language.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.