XML 处理
来源:互联网 发布:c语言数据类型有哪些 编辑:程序博客网 时间:2024/05/21 22:55
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 + "\\ProductDatafeedConfig\\ProductDatafeed.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 + "配置错误");
}
public string GetConfig(string itemName, string attributeName)
{
string key = itemName + "_" + attributeName;
if (datafeedConfig.ContainsKey(key))
{
return datafeedConfig[key];
}
string configPath = AppDomain.CurrentDomain.BaseDirectory + "\\ProductDatafeedConfig\\ProductDatafeed.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 + "配置错误");
}
- 处理xml
- XML 处理
- xml处理
- 处理 xml
- 处理XML
- XML 处理
- xml处理
- xml处理
- 使用XMLBeans 处理XML
- C#处理XML
- C# 处理XML文档
- 使用java处理XML
- C#处理XML
- Java处理XML学习
- xml文件处理经验总结
- DOM处理XML文件
- 处理XML数据
- 处理 XML 的 API
- Linux USB Gadget--软件结构
- Android APK安装常见错误
- SQL中判断字符串中包含字符的方法
- py2exe打包后dos窗口随着软件同启同关解决
- 二叉树遍历之递归、父结点、栈
- XML 处理
- Flex URLLoader 跨域访问weblogic发布的图像问题
- MySQL中文全文索引插件 mysqlcft 1.0.0 安装使用文档[原创]
- 第八周C++上机报告(项目3__分数运算符重载)
- Js五子棋游戏
- mq
- setup.py打包程序对资源文件的搜索方式
- WinCE下自动启动多个应用程序
- 如何提高学习效率 如何提高工作效率