|
-
Jun 26th, 2008, 04:07 PM
#1
Thread Starter
Hyperactive Member
[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","")
-
Jun 26th, 2008, 04:27 PM
#2
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|