原则与操作XML文件相同。
Private Sub SaveSetting(ByVal strKeyName As String, ByVal strKeyValue As String, ByVal strWhich As String)
'创建XML文档实例
Dim XMLWebSetting As System.Xml.XmlDocument = New System.Xml.XmlDocument
'打开XML文档
XMLWebSetting.Load(System.Web.HttpContext.Current.Server.MapPath("~/" + strWhich + ""))
'查找节点所在位置
Dim XmlNodeList As System.Xml.XmlNodeList = XMLWebSetting.SelectSingleNode("//appSettings").ChildNodes
Dim xn As System.Xml.XmlNode
Dim xe As System.Xml.XmlElement
Try
For Each xn In XmlNodeList
xe = CType(xn, System.Xml.XmlElement)
If xe.Attributes("key").InnerText = strKeyName Then
xe.Attributes("value").InnerText = strKeyValue
XMLWebSetting.Save(System.Web.HttpContext.Current.Server.MapPath("~/" + strWhich + ""))
Exit For
End If
Next
Catch
End Try
End Sub
本文作者:Eray 来源:http://blog.csdn.net/Eray/
CIO之家 www.ciozj.com 微信公众号:imciow