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 + "配置错误"); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- reactjsweekly -- React Chrome Dev Tool!! React.js开发者
- ruby – 如何多次运行同一个类?
- swift单例
- 使用正则将获取的网页中的所有HTML标记清空
- oracle – 有没有办法访问私人plsql程序进行测试?
- c# – 使用.net标准以编程方式创建服务总线订阅
- reactor-netty的TcpClient如何往eventLoop提交task
- Flex:将未实现的UIComponent渲染为BitmapData?
- reactjs – React Router将IndexRoute重定向到正确的路径
- 在PostgreSQL中使用PL/pgSQL返回多个字段作为记录