XML文件如下:
- <?xml version="1.0" encoding="utf-8"?>
- <root>
- <transDate>2014-12-18</transDate>
- </root>
C#读取与修改
- string xmlpath = System.AppDomain.CurrentDomain.BaseDirectory + "config.xml";
- XmlDocument doc = new XmlDocument();
- doc.Load(xmlpath);
- XmlNode xn = doc.SelectSingleNode("//transDate");
- string transDate = xn.InnerText;
- xn.InnerText = value;
- doc.Save(xmlpath);