加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

XML 处理

发布时间:2020-12-15 23:49:40 所属栏目:百科 来源:网络整理
导读:private readonly Dictionarystring,string datafeedConfig = new Dictionarystring,string(); public string GetConfig(string itemName,string attributeName) { string key = itemName + "_" + attributeName; if (datafeedConfig.ContainsKey(key)) { ret
private readonly Dictionary<string,string> datafeedConfig = new Dictionary<string,string>(); public string GetConfig(string itemName,string attributeName) { string key = itemName + "_" + attributeName; if (datafeedConfig.ContainsKey(key)) { return datafeedConfig[key]; } string configPath = AppDomain.CurrentDomain.BaseDirectory + "ProductDatafeedConfigProductDatafeed.config"; var xmlDocument = new XmlDocument(); xmlDocument.Load(configPath); XmlNode root = xmlDocument.SelectSingleNode("ProductDatafeed"); if (root != null) { var selectSingleNode = root.SelectSingleNode(itemName); if (selectSingleNode != null) { if (selectSingleNode.Attributes != null) { XmlAttribute item = selectSingleNode.Attributes[attributeName]; if (item != null) { datafeedConfig.Add(key,item.Value); return item.Value; } throw new ApplicationException("未在" + configPath + "找到指定的配置项"); } } } throw new ApplicationException(configPath + "配置错误"); }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读