引用:using System.Xml;---------------------------------读取XML,以数组的形式存-------------------------- public string[] GetConfigSet() { string[] ConfigSet = new string[2]; XmlDocument doc = new XmlDocument(); doc.Load(HttpContext.Current.Server.MapPath("~/App_Data/DutySet.xml")); string xPath = "//DutySet/SysConfig/isForeign"; XmlNode xmlNode = doc.SelectSingleNode(xPath); ConfigSet[0] = xmlNode.FirstChild.Value; xPath = "//DutySet/SysConfig/foreign"; xmlNode = doc.SelectSingleNode(xPath); ConfigSet[1] = xmlNode.FirstChild.Value; xPath = "//DutySet/SysConfig/seriousCo-ordination"; xmlNode = doc.SelectSingleNode(xPath); ConfigSet[2] = xmlNode.FirstChild.Value; return ConfigSet; }-------------------------------------保存XML--------------------------------------- protected void lnkbSave_C_Click(object sender, EventArgs e) { XmlDataDocument doc = new XmlDataDocument(); doc.Load(Server.MapPath("~/App_Data/DutySet.xml")); string xPath = string.Empty; XmlNode xmlNode; xPath = "//DutySet/SysConfig/isForeign"; xmlNode = doc.SelectSingleNode(xPath); xmlNode.FirstChild.Value = this.txtIsForeign.Text.Trim(); xPath = "//DutySet/SysConfig/transportation"; xmlNode = doc.SelectSingleNode(xPath); xmlNode.FirstChild.Value = this.txtTransportation.Text.Trim(); doc.Save(Server.MapPath("~/App_Data/DutySet.xml")); }