我有一個名爲app.exe.config的.config文件,我想更新一個名爲地址存在於端點標記內的特定屬性值。我嘗試了下面的代碼,但是不能得到什麼問題。我是vb.net的新手。請幫助。更新xml文件(.config文件)中的屬性值
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup>
<system.serviceModel>
<client>
<endpoint address="valuetobeupdated"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_CompassSMSService"
contract="CompassSMSService.CompassSMSService" name="BasicHttpBinding_CompassSMSService" />
</client>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_CompassSMSService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
我用下面的代碼,但它無法
Dim str As String = "Demo"
Dim doc As XmlDocument = New XmlDocument()
doc.Load("C:\Users\e554\Desktop\PAC\app.exe.config")
'Dim formId As XmlAttribute
For Each Attribute As XmlAttribute In doc.DocumentElement.Attributes
MessageBox.Show(Attribute.Value)
Next
:你給了一個很好的鏈接。謝謝 – Kenta