我有一个以下格式的 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<server xmlns="urn:jboss:domain:1.2">
<extensions>
<extension module="org.jboss.as.clustering.infinispan" />
<extension module="org.jboss.as.cmp" />
<extension module="org.jboss.as.ejb3" />
</extensions>
<appSettings>
<property name="EXTERNAL_FILESERVER" value="/site/bugbase.adobe.com/files/" />
<property name="FTP_USER" value="password" />
<property name="FTP_SERVER" value="sjshare.corp.adobe.com"/>
<property name="FTP_PASSWORD" value="password" />
<property name="FTP_READ_USER" value="password" />
<property name="FTP_READ_PASS" value="password" />
<property name="WORKFLOW_NOTIFICATION_TEMPLATE" value="util/workflow_notification_template.html"/>
</appSettings>
</server>
我想更改“FTP_USER”和“FTP_READ_USER”的密码值。
到目前为止我尝试过的代码:
XmlDocument doc = new XmlDocument();
string path = @"C:\Users\karansha\Desktop\config file 1.xml";
doc.Load(path);
doc.SelectNodes("/appSettings/property").Item(1).Attributes["value"].Value = "newpassword";
doc.SelectNodes("/appSettings/property").Item(2).Attributes["value"].Value = "new_password";