string file = ServerMapPath(@"~\webconfig");
XmlDocument xmlDoc = new XmlDocument();
xmlDocLoad(file);
string s1 = "aaa";
string s2 = "bbb";
string h = "ccc";
string user = "ddd";
string pass = "eee";
XmlNodeList nodeList = null;
nodeList = xmlDocSelectSingleNode("configuration//connectionStrings")ChildNodes;
//遍历所有子节点
foreach (XmlNode xn in nodeList)
{
//将子节点类型转换为XmlElement类型
XmlElement xe = xn as XmlElement;
if (xeName == "add")
{
if (xeGetAttribute("name") == "acountConnectionString")
{
xeSetAttribute("connectionString", s1);
}
if (xeGetAttribute("name") == "mailaddress")
{
xeSetAttribute("connectionString", s2);
}
}
}
nodeList = xmlDocSelectSingleNode("configuration//systemnet//mailSettings//smtp")ChildNodes;
foreach (XmlNode xn in nodeList)
{
//将子节点类型转换为XmlElement类型
XmlElement xe = xn as XmlElement;
if (xeName == "network")
{
xeSetAttribute("host", h);
xeSetAttribute("userName", user);
xeSetAttribute("password", pass);
break;
}
}
xmlDocSave(file);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)