正在阅读:多线程加载多个Xml文件到TreeView控件多线程加载多个Xml文件到TreeView控件

2004-06-11 10:04 出处:CSDN 作者:zhzuo [翻译] 责任编辑:linjixiong

  如果你看了ParserThread类的CreateThread方法,那上面的parserMethod方法就很清楚了。我们成功的完成了参数的传递。下面是process_xml方法:


public  void process_xml(String name)

{
     try
     {
         XmlDocument doc = new XmlDocument();

         String fname = name;

         doc.Load(fname);

         XmlNodeList nList1;

         XmlNodeList nList2;

         XmlNodeList nList;

         nList=doc.GetElementsByTagName("EmpDataSet");

         for( int m =0;m<nList.Count;m++)

         {
              XmlElement element_main = (XmlElement)nList.Item(m);//emp_table
              nList1 = element_main.ChildNodes ;//Emps
              for( int k =0;k<nList1.Count;k++)
              {
                   XmlElement element_fchild = (XmlElement)nList1.Item(k);
                   nList2 = element_fchild.ChildNodes ;
                   IEmpDetails emp = new EmpDetails();
                   if( m_bAbort)
                   {
                       return;
                   }
                   for( int j =0;j<nList2.Count;j++)
                   {
                       XmlElement child_element = (XmlElement)nList2.Item(j);
                       if( child_element.Name == "Emp_id" )
                       {
                            emp.empId = System.Convert.ToInt32(child_element.InnerText);
                        }
                       if( child_element.Name == "Emp_Name" )

                       {
                            emp.empName = child_element.InnerText;
                       }
                       if( child_element.Name == "Emp_Address" )
                       {
                            emp.empAddress = child_element.InnerText;
                       }





察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:

键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品