What is the code for DOM OR XPATH to connect xml file connection in my code(project)
How can I do this ,please help me ?
How can I do this ,please help me ?
Public Function GetXmlConnection() As String
Dim connection As String = ""
Dim xml As New XmlDocument()
xml.Load(HttpContext.Current.Server.MapPath("~/App_Data/XmlReadSource.xml"))
Dim root As XmlNode = xml.SelectSingleNode("configuration")
Dim child As XmlNodeList = root.ChildNodes
For Each c As XmlNode In child
If TryCast(c, XmlElement).Name = "appsettings" Then
Dim xnl As XmlNodeList = c.ChildNodes
For Each xnf As XmlNode In xnl
Dim xe As XmlElement = DirectCast(xnf, XmlElement)
If xe.GetAttribute("key") = "constr" Then
connection = xe.GetAttribute("value")
Else
Continue For
End If
Next
Else
Continue For
End If
Next
Return connection
End Function
Comment