private readonly Dictionary<string,string>
datafeedCon
fig = new Dictionary<string,string>(); public string GetCon
fig(string itemName,string attributeName) { string key = itemName + "_" + attributeName; if (
datafeedCon
fig.ContainsKey(key)) { return
datafeedCon
fig[key]; } string con
figPath = AppDomain.CurrentDomain.BaseDirectory + "\\Product
datafeedCon
fig\\Product
datafeed.con
fig"; var xmlDocument = new XmlDocument(); xmlDocument.Load(con
figPath); XmlNode root = xmlDocument.SelectSingleNode("Product
datafeed"); if (root != null) { var selectSingleNode = root.SelectSingleNode(itemName); if (selectSingleNode != null) { if (selectSingleNode.Attributes != null) { XmlAttribute item = selectSingleNode.Attributes[attributeName]; if (item != null) {
datafeedCon
fig.Add(key,item.Value); return item.Value; } throw new ApplicationException("未在" + con
figPath + "找到指定的配置项"); } } } throw new ApplicationException(con
figPath + "配置
错误"); }
原文地址:https://www.jb51.cc/xml/300544.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。