Results 1 to 2 of 2

Thread: [2005] XML Class, do I have it right?

  1. #1

    Thread Starter
    Hyperactive Member maikeru-sama's Avatar
    Join Date
    May 2008
    Posts
    339

    [2005] XML Class, do I have it right?

    As some may know, I am moving from INI to XML. I want to get this right and use what most people on here use. I have written a "GetXMLValue" function and would like you all to evaluate it and see if it makes sense:

    Code:
        'get xml value
        Public Function GetXMLValue(ByVal Node As String, ByVal [Default] As String) As String
            Dim RetVal As String
            Dim xmlDoc As New XmlDocument
            Dim xmlNode As XmlNode
    
            Try
                'load document
                xmlDoc.Load(Application.StartupPath & "\TShed.xml")
                'get node value
                xmlNode = xmlDoc.SelectSingleNode(Node)
                RetVal = xmlNode.Value
                'check return value
                If RetVal = "" Then
                    RetVal = [Default]
                End If
            Catch ex As Exception
                Throw New Exception(ex.Message & " - GetXMLValue(string)")
            Finally
                xmlNode = Nothing
                xmlDoc = Nothing
            End Try
    
            Return RetVal
        End Function
    You would pass in something like:
    Version = GetXMLValue("/Myapp/Version","")

  2. #2

    Thread Starter
    Hyperactive Member maikeru-sama's Avatar
    Join Date
    May 2008
    Posts
    339

    Re: [2005] XML Class, do I have it right?

    I am actually going to make the Functions more specialized so you don't have to pass in such big node locations.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width