zoukankan      html  css  js  c++  java
  • 读取XML数据到treeView中

    代码如下

      /// <summary>
            
    ///   绑定xml数据到treeview中区
            
    /// </summary>
            public void bindXmlToTreeView(XmlNodeList nodeList,TreeNodeCollection treeNode)
            {
            
                foreach (XmlNode node in nodeList)
                {
                    XmlElement xe = (XmlElement)node;
                    TreeNode newTreeNode = new TreeNode();
                    newTreeNode.Text = xe.GetAttribute("name");
                    newTreeNode.Name = xe.GetAttribute("value");
                    treeNode.Add(newTreeNode);
                    
                    if (node.HasChildNodes)
                    {
                        bindXmlToTreeView(node.ChildNodes,newTreeNode.Nodes);
                    }
                }

            } 


    使用:



    XmlDocument xmlDoc = new XmlDocument();//
    XmlNodeList currentXmlNodeList = null;    

    xmlDoc.Load(baseDir); 

    currentXmlNodeList = xmlDoc.SelectNodes("/root/GasTree");

    bindXmlToTreeView(currentXmlNodeList,treeView1.Nodes);

  • 相关阅读:
    java wait方法
    thread join
    AtomicReference 原理
    exchanger java另一种栅栏
    CyclicBarrier 栅栏 原理,应用场景
    信号量Semaphore
    FutureTask 解析
    CountDownLatch
    java 双端队列 Deque
    lockInterruptibly 和lock 原理
  • 原文地址:https://www.cnblogs.com/ylwn817/p/2288512.html
Copyright © 2011-2022 走看看