예제 #1
0
        //加载XML文件,数据扔到类的成员allTestNode
        public static Boolean LoadTestXMLFile(string sXmlFile)
        {
            //xml文档信息
            XmlDocument t_XmlDoc = new XmlDocument();

            try
            {
                File.Copy(sXmlFile, sXmlFile + ".bak", true); //create a backup-file
                t_XmlDoc.Load(sXmlFile);                      //use try to catch possible xml file format errors
                //选中表格名
                XmlNodeList nodelist = t_XmlDoc.SelectNodes("/*/testtable");

                TestTree.m_AllTestNode.Clear();
                foreach (XmlNode node in nodelist)
                {
                    TestTree tmpNode = new TestTree(node);

                    //if (tmpCmd.CMDParentId == 0)
                    TestTree.m_AllTestNode.Add(tmpNode);
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
예제 #2
0
        //把对象信息加入表中
        public void AddNodeToTestData(TestTree node, ref DataTable table)
        {
            object[] t_Object = new object[table.Columns.Count];

            foreach (DataColumn col in table.Columns)
            {
                t_Object[col.Ordinal] = node.GetValue(col.ColumnName);
            }

            table.Rows.Add(t_Object);
        }
예제 #3
0
 //读xml文件,信息读入绑定树控件的表中
 public void LoadTestXML(string sxmlFile)
 {
     if (TestTree.LoadTestXMLFile(sxmlFile))
     {
         //清空节点
         testTreeView.Nodes.Clear();
         //清除表格所有的数据
         m_TestDataTable.Clear();
         foreach (TestTree node in TestTree.m_AllTestNode)
         {
             AddNodeToTestData(node, ref m_TestDataTable);
         }
     }
 }