鬼门关梦

博客园 首页 新随笔 联系 订阅 管理
 1  ArrayList al = new ArrayList();
 2             try
 3             {
 4                 XmlDocument xmlDoc = new XmlDocument();
 5                 string xmlPath = Application.StartupPath + "\\Config\\UpdateDataTable.xml";
 6                 XmlDocument xmlDoc1 = new XmlDocument();
 7                 xmlDoc.Load(xmlPath);
 8 
 9                 XmlNode rootNode = xmlDoc.SelectSingleNode("LoadTable");
10                 XmlNodeList firstLevelNodeList = rootNode.ChildNodes;
11                 foreach (XmlNode node in firstLevelNodeList)
12                 {
13 
14                     XmlElement xe = (XmlElement)node;
15                     if (xe.GetAttribute("Name").ToString() != " " && xe.GetAttribute("IsStart").ToString() == "")
16                     {
17                         al.Add(xe.GetAttribute("Name").ToString());
18                     }
19                 }
20             }
21             catch
22             {
23                 this.timer1.Enabled = false;
24                 MessageBox.Show("读取配置文件出错!");
25                 this.Dispose();
26                 this.Close();
27             }


配置文件如下:

<?xml version="1.0" encoding="GB2312"?>
<LoadTable>
  <DataTable Name="PROCESS_STAFFONLINERECORD" IsStart="" Tag="0">
  </DataTable>
  <DataTable Name="STATIONLIST" IsStart="" Tag="0">
  </DataTable>
  <DataTable Name="STATIONDEVICE" IsStart="" Tag="0">
  </DataTable>  
</LoadTable>

 

posted on 2012-07-28 11:19  鬼门关梦  阅读(243)  评论(0编辑  收藏  举报