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:
You would pass in something like: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
Version = GetXMLValue("/Myapp/Version","")




Reply With Quote