zoukankan      html  css  js  c++  java
  • 华途软件受控XML转EXCEL

          公司加密系统用的是华途的产品。最近公司高层想要重新梳理公司信息安全管理情况,华途加密系统的梳理和优化是重中之重。

          今天公司领导要求IT导出目前系统中所有软件、后缀的受控情况,然后IT吭哧吭哧地把华途软件中的XML发给领导了,结果领导根本不知道如何打开XML文件。等到领导用IE打开XML后,看到的是满屏幕的天书。IT的下场我只能说:老惨了。。。

          领导看到的XML如下图:

    这个XML的格式还是很清晰的:ModuleInfo定义了软件的版本,进程标识,分类,控制类型等信息。  Include节点下面定义了要控制的文件后缀,Exclude节点下面定义了不控制的文件后缀。

    所以,解决这个问题的思路很简单:通过代码读取这个XML文件,转义成领导能看懂的格式,存成EXCEL即可。

    //定义结果集
    scList = new List<SecureControl>();
    //读取XML文件
    string xmlFile = Path.Combine(Application.StartupPath, "XML", "config.xml");
    XElement xele = XElement.Load(xmlFile);
    //读取ModuleInfo节点集合
    IList<XElement> a = xele.Descendants("ModuleInfo").ToList(); //ModuleInfo

    foreach (XElement x in a)
    {
    try
    {
    //读取节点属性,取得软件版本等信息。
    SecureControl sc = new SecureControl();
    sc.IsCharacteristic = x.Attribute("IsCharacteristic").Value;
    sc.IsControled = x.Attribute("IsControled").Value;
    sc.Process = x.Attribute("Process").Value;
    sc.SoftType = x.Attribute("SoftType").Value;
    sc.SoftVersion = x.Attribute("SoftVersion").Value;
    sc.Include = "";
    sc.Exclude = "";
    //遍历读取Include
    IList<XElement> include = x.Descendants("Include").Descendants("FileType").ToList();
    foreach (XElement ic in include)
    {
    sc.Include += (ic.Value + " ");
    }
    //遍历读取Exclude
    IList<XElement> exclude = x.Descendants("Exclude").Descendants("FileType").ToList();
    foreach (XElement ex in exclude)
    {
    sc.Exclude += (ex.Value + " ");
    }
    //插入结果集,用于显示
    scList.Add(sc);
    }
    catch
    { }
    }

    gridControl1.DataSource = scList;

    效果展示:

    读取界面

    存成的Excel:

  • 相关阅读:
    通过ifconfig命令分析
    网络协议初探
    商品详情页面属性价格显示其对应价格
    ecshop属性 {$goods.goods_attr|nl2br} 标签的赋值相关
    CI模板中如何引入模板
    jQuery取得/设置select的值
    ecshop如何增加多个产品详细描述的编辑器
    获取span里面的值(特殊情况下 )
    一个页面有相同ID元素的情况分析
    表单辅助函数-form_open()
  • 原文地址:https://www.cnblogs.com/huangdashen/p/9805948.html
Copyright © 2011-2022 走看看