Asp.Net 读取xml文件中Key的值,并且过滤掉注释内容代码

2020-11-17 01:44

阅读:478

标签:des   style   blog   class   code   java   javascript   color   get   string   文件   

mamicode.com,搜素材
      /// 
        /// 读取配置文件keys
        /// 
        /// 
        public string _GetKeys()
        {
            string filename = Server.MapPath("/") + @"web.config";
            XmlDocument xmldoc = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            settings.IgnoreWhitespace = true;
            XmlReader reader = XmlReader.Create(filename, settings);
            xmldoc.Load(reader);
            XmlNodeList topM = xmldoc.DocumentElement.ChildNodes;
            foreach (XmlElement element in topM)
            {
                if (element.Name == "appSettings")
                {
                    XmlNodeList node = element.ChildNodes;
                    if (node.Count > 0)
                    {
                        foreach (XmlElement el in node)
                        {
                            string str = el.Attributes["key"].Value.ToString();
                            AppConfigKeys += str.ToString() + ",";
                        }
                    }
                }
            }
            return AppConfigKeys;
        }
mamicode.com,搜素材

 

Asp.Net 读取xml文件中Key的值,并且过滤掉注释内容代码,搜素材,soscw.com

Asp.Net 读取xml文件中Key的值,并且过滤掉注释内容代码

标签:des   style   blog   class   code   java   javascript   color   get   string   文件   

原文地址:http://www.cnblogs.com/leichentao0905/p/3700676.html


评论


亲,登录后才可以留言!