Reads a key value from certain section in Config.web
Originally from

'****************************** ConfigWeb_Read *******************************
' Purpose:  Utility function to get value from a configuration file.
' Conditions: CONFIG_FILE_PATH must be refer to a valid XML file
' Input:   sectionName - a section in the file, eg, appSettings
'      attrName - refers to the "key" attribute of an entry
' Output:  A string containing the value of the appropriate entry

CONFIG_FILE_PATH="Web.config" 'if no qualifier, refers to this directory. can point elsewhere.
Function ConfigWeb_Read(sectionName, attrName)
 Dim oXML, oNode, oChild, oAttr, dsn
 Set oXML=Server.CreateObject("Microsoft.XMLDOM")
 oXML.Async = "false"
 Set oNode = oXML.GetElementsByTagName(sectionName).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("value")
   ConfigWeb_Read = dsn
   Exit Function
  End If
End Function

sectionName, attrName

settingValue = ConfigWeb_Read (&#34;appSettings&#34;, &#34;someKeyName&#34;)<br/>Response.Write(settingValue)

Views 1344 Downloads 554

'CONFIG_FILE_PATH', 'Config', 'web', 'read', 'value', 'setting', 'session', 'key', 'attrname', 'section', 'NotMyWork', 'NotTested'

Components Classic ASP