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>