保存与设置 XML的方法

            string parms = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                            <Params>
                             <ExcelRule>{0}</ExcelRule>
                             <ExcelFile>{1}</ExcelFile>
                             <Handle>{2}</Handle>
                             <SavePath>{3}</SavePath>
                            </Params>";

            parms = string.Format(parms, _excelRule, _excelFile, this.Handle, _excelSavePath);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(parms);
            doc.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"ExcelToGSP\Params.xml"));


            //XmlDocument doc = new XmlDocument();
            //doc.Load(AppDomain.CurrentDomain.BaseDirectory + @"ExcelToGSP\Params.xml");
            //doc.SelectSingleNode("Params/ExcelRule").InnerText = ExcelRule;
            //doc.SelectSingleNode("Params/ExcelFile").InnerText = ExcelFile;
            //doc.SelectSingleNode("Params/Handle").InnerText = ExcelHandle;
            //doc.SelectSingleNode("Params/SavePath").InnerText = SavePath;

posted @ 2011-04-18 19:59  smodi  阅读(321)  评论(0编辑  收藏  举报