doc.config,如下<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="connectionString" value="server=localhost;database=CWork;User Id=sa;pwd=780208;"/>
<add key="Debug" value="True" />
</appSettings>
</configuration>
要求:
读取 connectionstring 的 value
我的写法:
Public Property readonly AppSettings(ByVal key As String)
get
dim doc As System.Xml.XmlDocument
doc = New XmlDocument
doc.Load(doc.xml)
Dim node As System.Xml.XmlNode
node = doc.SelectSingleNode("/configuration/appsettings/add[@key='" & key & "']")
'node 是空的?为何
end get
或C#的解决代码也可以的,谢谢
<configuration>
<appSettings>
<add key="connectionString" value="server=localhost;database=CWork;User Id=sa;pwd=780208;"/>
<add key="Debug" value="True" />
</appSettings>
</configuration>
要求:
读取 connectionstring 的 value
我的写法:
Public Property readonly AppSettings(ByVal key As String)
get
dim doc As System.Xml.XmlDocument
doc = New XmlDocument
doc.Load(doc.xml)
Dim node As System.Xml.XmlNode
node = doc.SelectSingleNode("/configuration/appsettings/add[@key='" & key & "']")
'node 是空的?为何
end get
或C#的解决代码也可以的,谢谢
使用跟节点方式试验一下