title: Having classic ASP read in a key from appsettings in a web.config file
body: <p>OK so here's the situation.  I've got a classic ASP website running inside an MVC 4 application.  I need the classic ASP website to be able to get a key from the appsettings section of the web.config file.</p>
  
  <p>Here is the function I've got:</p>
  
  <pre><code>' Imports a site string from an xml file (usually web.config)
  Function ImportMySite(webConfig, attrName, reformatMSN)
      Dim oXML, oNode, oChild, oAttr, dsn
      Set oXML=Server.CreateObject("Microsoft.XMLDOM")
      oXML.Async = "false"
      oXML.Load(Server.MapPath(webConfig))
      Set oNode = oXML.GetElementsByTagName("appSettings").Item(0) 
      Set oChild = oNode.GetElementsByTagName("add")
      ' Get the first match
      For Each oAttr in oChild 
          If  oAttr.getAttribute("key") = attrName then
              dsn = oAttr.getAttribute("mysite")
              ImportMySite = dsn
              Exit Function
          End If
      Next
  End Function
  </code></pre>
  
  <p>Here is the function call code:</p>
  
  <pre><code>msn = ImportMySite("web.config", "mysite", false)
  </code></pre>
  
  <p>So when I call this function the value I get back is always blank or null.  I'm not sure where I'm going wrong, I'm a total novice with XML so maybe I'm missing something completely obvious.  I have searched the questions but couldn't find anything related to this using classic ASP.</p>
  
  <p>Any help would be much appreciated.</p>