C#读写xml文件的简单范例
//读配置文件 XmlDocument doc = new XmlDocument(); doc.Load("blog.xml"); XmlNode url = doc.SelectSingleNode("博客/广告地址"); texturl.Text = url.InnerText; XmlNode Name = doc.SelectSingleNode("博客/用户名1"); name = Name.InnerText; XmlNode Password = doc.SelectSingleNode("博客/密码1"); password = Password.InnerText; XmlNode dbid = doc.SelectSingleNode("博客/DBID"); DBID = int.Parse(dbid.InnerText); //写配置文件 XmlDocument doc = new XmlDocument(); doc.Load("blog.xml"); XmlNode xiugai = doc.SelectSingleNode("博客"); xiugai["DBID"].InnerText = DBID.ToString(); //修改值 doc.Save("blog.xml");