Search KB Filter article types
Accessing configuration files programatically CodeSample - XML reading PrivateVersion
Categories: Configuration, Resources
Tags: Architects, Developers, XML, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
Revision: 1
Posted: 20/Sep/2009
Updated: 23/July/2010
Status: Publish
Types: Code

This article will have a few sections added to it soon, based on the following article type skeleton: CodeSample
Overview

This codesample shows how to use generic XML reading of web.config to read whatever value you choose from that file. In this sample we read the PrivateVersion setting.

VB.NET Code
Imports System.IO
Imports System.Xml
 
Public Function GetPrivateVersion(ByVal webConfigPath As String) As Integer
    Dim ret As Integer = 0
 
    'Retrieve the physical path of the web.config file.
    Dim configXmlDoc As New XmlDocument()
    configXmlDoc.Load(webConfigPath)
 
    ' read the config settings
    Dim oList As XmlNodeList = configXmlDoc.SelectNodes("configuration/WebGui/PrivateVersion")
    For i As Integer = 0 To oList.Count - 1
        If oList(i).Name = "PrivateVersion" Then
            Dim oValue As XmlAttribute = oList(i).Attributes("Value")
            ret = CInt(oValue.Value)
        End If
    Next
    configXmlDoc = Nothing
    Return ret
End Function

C# Code
The conversion of this code to C# has not been completed yet.

About the author

Related Articles

Configuration  
Title Update Author
Visual WebGui version 6.2 features complete integration into the Microsoft Visual Studio development system, a consolidated installation process, and the opportunity to use Microsoft Visual Studio Express Editions for software evaluation and trials. Attend this webcast to learn how the Visual WebGui...
Tags: Developers, Visual WebGui Pipeline, Visual Studio, 1. Beginner, 2. Intermediate, 3. Advanced, Integration, Pre v6.3, v6.3, v6.4 and Later
11/Jan/2008    2008/01/11
Tags: Developers, 2. Intermediate, 3. Advanced, Customization, WCF, Pre v6.3, v6.3, v6.4 and Later
06/Jan/2009    2009/01/06
Tags: Architects, Developers, XML, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
29/Oct/2010    2010/10/29
Tags: Architects, Developers, XML, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
23/July/2010    2010/07/23
Tags: Architects, Developers, XML, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
23/July/2010    2010/07/23
Tags: Architects, Developers, XML, 1. Beginner, 2. Intermediate, 3. Advanced, Pre v6.3, v6.3, v6.4 and Later
04/Dec/2010    2010/12/04