C# 操作xml文件

时间:2015-02-03 14:54:53   收藏:0   阅读:266

  /// <summary>
        /// 修改XML
        /// </summary>
        /// <param>test</param>
        public static void ChangeXml(string test)
        {
            string xmlPath = "config";//当前文件夹下的config
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(xmlPath);
            XmlNodeList settings = xmlDoc.SelectNodes("configuration/applicationSettings/setting");
            foreach (XmlNode node in settings)
            {
                XmlNode valueNode = node.SelectSingleNode("value");
                string[] uri = valueNode.InnerText.Split(‘/‘);
                valueNode.InnerText = "http://" + test + "/" + uri[uri.Length - 1];
            }
            xmlDoc.Save(configPath);
        }

原文:http://www.cnblogs.com/anyben/p/4269868.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!