Hi,
I have found a very useful piece of code in the msdn which shows how to load
an xml config file, search for a particular value and replace it.
Could someone possibly convert it to C# from the VB I have?
I also would like to use similar code to update the machine.config file so
if someone could explain how to add a node ("appSettings") if node not found
and also how to add a key value pair into the "appSettings" node if found I
would be extremely grateful.
The code snippet I have from msdn is as follows
' Loads the config file into the XML DOM.
Dim XmlDocument As New System.Xml.XmlDocument()
XmlDocument.Load(FileInfo.FullName)
' Finds the right node and change it to the new value.
Dim Node As System.Xml.XmlNode
Dim FoundIt As Boolean = False
For Each Node In XmlDocument.Item("configuration").Item("appSetting s")
If Node.Name = "add" Then ' skip any comments
If Node.Attributes.GetNamedItem("key").Value = "ServerName" Then
Node.Attributes.GetNamedItem("value").Value = ProvidedName
FoundIt = True
End If
End If
Next Node
Apologies if this is the wrong group, I am happy to repost to a more correct
one if someone can point me the way.
--
KM