Simple XML question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Brian Henry (brianiup[nospam)
Date: 02/13/04


Date: Fri, 13 Feb 2004 15:00:14 -0500

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



Relevant Pages

  • Re: Grabbing string values from the end of a string of an unknown
    ... having to specify the parameter values/never run macros unless excel has just ... Not if the string is produced by a formula. ... shown below in this recorded macro are restored. ... The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each ...
    (microsoft.public.excel.programming)
  • Re: how to write to an xml file
    ... Create an object representation of the xml file and fill it with data: ... string Value; ... string ReportName; ... Settings settingsObject=new Settings; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: remoting object access information from local xml file frequenctly
    ... You can definately use an object on your server to load the xml file ... I would do is create a class that loads the xml file settings into the ... server's memory and then create a shared ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: WebService update
    ... external server. ... I want to know how to update at runtime the webservice object of my ... App.config is just another XML file. ... You create a routine on a Timer and read the app.comfit periodically to pick up new settings, using an XML Document object, to pick-up the new URL. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Remember Previous Settings for an Application
    ... write to an XML file from VB.net? ... My.SEttigns and the settings designer. ... Dim setting1 As String = doc....Value ...
    (microsoft.public.dotnet.languages.vb)