B
Brian Henry
I have an XML file formated as this
<?xml version="1.0" encoding="utf-8" ?>
<settings>
<databaseServer>Dell5100</databaseServer>
<defaultDatabase>bene</defaultDatabase>
</settings>
relateively simple file... I want to be able to say which attribute of the
settings group I want to read in a settings read function and return it...
how would i do this? below is the code I have so far, but it requires an
index of the node to read.. how would i specify that i want the database
server item or the defaultdatabase item? i cant by index since im asking for
it by a string value ... here is my code i have, any help would be nice,
thanks!
' reads a setting from xml settings file
Public Shared Function ReadSetting(ByVal settingName As String) As String
Try
' I want to find the attribute named with the name specified in settingname
and return it to the user out of the settings group of the XML file
XMLDocument = New XmlDocument
XMLDocument.Load(bdb.applicationPath & "\benesettings.xml")
XMLNode = XMLDocument.SelectSingleNode("/settings")
Debug.WriteLine("XML READ: " & XMLNode.ChildNodes.Item(0).InnerText)
' here is where it wants the index... i put zero in for an example to test
the load but now i need to find the attribute value by the settingname
specified
Catch ex As Exception
MessageBox.Show("XML Load Error" & ControlChars.CrLf & ex.Message)
End Try
End Function
<?xml version="1.0" encoding="utf-8" ?>
<settings>
<databaseServer>Dell5100</databaseServer>
<defaultDatabase>bene</defaultDatabase>
</settings>
relateively simple file... I want to be able to say which attribute of the
settings group I want to read in a settings read function and return it...
how would i do this? below is the code I have so far, but it requires an
index of the node to read.. how would i specify that i want the database
server item or the defaultdatabase item? i cant by index since im asking for
it by a string value ... here is my code i have, any help would be nice,
thanks!
' reads a setting from xml settings file
Public Shared Function ReadSetting(ByVal settingName As String) As String
Try
' I want to find the attribute named with the name specified in settingname
and return it to the user out of the settings group of the XML file
XMLDocument = New XmlDocument
XMLDocument.Load(bdb.applicationPath & "\benesettings.xml")
XMLNode = XMLDocument.SelectSingleNode("/settings")
Debug.WriteLine("XML READ: " & XMLNode.ChildNodes.Item(0).InnerText)
' here is where it wants the index... i put zero in for an example to test
the load but now i need to find the attribute value by the settingname
specified
Catch ex As Exception
MessageBox.Show("XML Load Error" & ControlChars.CrLf & ex.Message)
End Try
End Function