Hello Mat

 找回密码
 立即注册
查看: 6129|回复: 0

xml文件读

[复制链接]

1298

主题

1524

帖子

114

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22653
发表于 2019-7-18 22:34:05 | 显示全部楼层 |阅读模式
xml文件读:
  1. public void ReadXml(string xmlPath, ref Dictionary<string, string> imageProcessParams)
  2.         {
  3.             try
  4.             {
  5.                 XElement xRoot = XElement.Load(xmlPath);
  6.                 IEnumerable<XElement> xAlgorithms = xRoot.Elements("Algorithm");
  7.                 List<Tuple<string,string,string>> AlgorithmsParametersInfo=(from i in xAlgorithms
  8.                                                                                 select Tuple.Create<string,string,string>(
  9.                                                                                 i.Attribute("dllName").Value,
  10.                                                                                 i.Attribute("className").Value,
  11.                                                                                 i.Attribute("algorithmName").Value)).ToList();
  12.                //var AlgorithmData = (from i in xRoot.Elements("Algorithm")
  13.                //                         where i.Attribute("className").Value=="ysw_threshold"
  14.                //                         select i).ToList();
  15.                //List<Tuple<string, string>> paramList = (from i in AlgorithmData.Elements("Params").Elements("Item")
  16.                //                                         select Tuple.Create(i.Attribute("name").Value,
  17.                //                                                             i.Attribute("defaultValue").Value
  18.                //                                                             )).ToList();
  19.                 List<Tuple<string, string>> paramList = (from i in xAlgorithms.Elements("Params").Elements("Item")
  20.                                                          select Tuple.Create(i.Attribute("name").Value,
  21.                                                                              i.Attribute("defaultValue").Value
  22.                                                                              )).ToList();
  23.                 imageProcessParams = null;
  24.                 imageProcessParams = new Dictionary<string, string>();
  25.                 imageProcessParams.Clear();
  26.                 foreach (var item in paramList)
  27.                 {
  28.                     imageProcessParams.Add(item.Item1, item.Item2);
  29.                 }
  30.             }
  31.             catch (Exception ex)
  32.             {

  33.             }
  34.         }
复制代码




算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-5-18 12:45 , Processed in 0.251816 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表