August 2006 Archives

Parsing an XML file from classic ASP

|

Part of an application I work on derives some of its configuration from the contents of a global.asa file, with configuration hard-coded. I've been looking at ways of separating the configuration out to make it easier to maintain and to understand. Using a simple structure of:


SettingValue
SettingValue
SettingValue

for the XML, and storing it in a file called "config.xml" with the appropriate permissions, obviously! I can then use the following code from ASP to parse this file and place the resultant information into the ASP Application object ready for use within any page:

Sub ReadAndParseXMLConfiguration()
' Called in Application_OnStart
Dim oXmlDocument
Set oXmlDocument = Server.CreateObject("Microsoft.XMLDOM")

oXmlDocument.Load(Server.MapPath("config.xml"))

If oXmlDocument.parseError.errorcode <> 0 Then
Err.Raise oXmlDocument.parseError.errorcode, ,oXmlDocument.parseError.reason
End If

Dim oXmlNode
For Each oXmlNode in oXmlDocument.documentElement.childNodes
Application(oXmlNode.NodeName) = oXmlNode.Text
Next
End Sub

I've managed to reduce the size of the global.asa, make it easier for non-developers to change configuration settings. Now all I've got to do is get the code change agreed!

Presentation Tips

|

[Via ScottGu's Blog] Ten Worst Presentation Moments

The IM notification one really made me smile.

Linkage

|

A Process for Performing Security Code Reviews
Advanced Basics: Predicates and Actions
The latter is the one of most interest to me as it actually explains the purpose, and usage, of predicates in a way that is much clearer than the MSDN / Visual Studio documentation for it. A very powerful tool to have under my belt methinks!

About this Archive

This page is an archive of entries from August 2006 listed from newest to oldest.

June 2006 is the previous archive.

September 2006 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 5.04