获取xml中指定属性的节点并改变值

XmlDocumentdoc=new XmlDocument();

doc.Load(configName);
XmlNode node=doc.SelectSingleNode("/configuration/appSettings/add[@key='test']");
if(node!=null)
{
    XmlElement e=(XmlElement)node;
    e.SetAttribute("value",val);      
}
doc.Save(configName);

 

posted @ 2015-04-08 08:29  清幽紫竹  Views(269)  Comments(0)    收藏  举报