Program to read value from AppSettings section in VB.Net using XDocument class

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 231
The below program will do the work

Imports System.Xml.Linq

Namespace MakeEnvVars
Class Program
Private Shared Sub Main(args As String())
Dim fileName As String = "D:\Web.config"
Dim doc As XDocument = XDocument.Load(fileName)
Dim message As String = String.Empty
Dim elements = doc.Descendants("appSettings").Descendants("add")
For Each element As XElement In elements
message = "SET {element.FirstAttribute.Value}=""{element.LastAttribute.Value}"""

End Sub
End Class
End Namespace

Comments or Responses

Login to post response