Hello Mat

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

xml文件写

[复制链接]

1294

主题

1520

帖子

110

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22633
发表于 2019-7-18 22:34:45 | 显示全部楼层 |阅读模式
xml文件写:
  1. public void WriteXml(string xmlPath, string AlgParam, double AlgParamValue)
  2.         {
  3.             try
  4.             {
  5.                 XElement xRoot = XElement.Load(xmlPath);
  6.                 IEnumerable<XElement> xAlgorithms = xRoot.Elements("Algorithm");
  7.                 foreach (XElement xn in xAlgorithms)
  8.                 {
  9.                     XElement xmlParams = xn.Element("Params");
  10.                     foreach (var item in xmlParams.Elements("Item"))
  11.                     {
  12.                         if (item.FirstAttribute.Value.ToString() == AlgParam)
  13.                         {
  14.                             item.LastAttribute.Value = Convert.ToString(AlgParamValue);
  15.                         }
  16.                     }
  17.                 }
  18.                 xRoot.Save(xmlPath);
  19.             }
  20.             catch (Exception ex)
  21.             {

  22.             }
  23.         }
复制代码



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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-27 06:01 , Processed in 0.222401 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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