您的位置:首页 > 其它

从配置文件xml中读取需要更新的表名

2012-07-28 11:19 429 查看
ArrayList al = new ArrayList();
try
{
XmlDocument xmlDoc = new XmlDocument();
string xmlPath = Application.StartupPath + "\\Config\\UpdateDataTable.xml";
XmlDocument xmlDoc1 = new XmlDocument();
xmlDoc.Load(xmlPath);

XmlNode rootNode = xmlDoc.SelectSingleNode("LoadTable");
XmlNodeList firstLevelNodeList = rootNode.ChildNodes;
foreach (XmlNode node in firstLevelNodeList)
{

XmlElement xe = (XmlElement)node;
if (xe.GetAttribute("Name").ToString() != " " && xe.GetAttribute("IsStart").ToString() == "是")
{
al.Add(xe.GetAttribute("Name").ToString());
}
}
}
catch
{
this.timer1.Enabled = false;
MessageBox.Show("读取配置文件出错!");
this.Dispose();
this.Close();
}


配置文件如下:

<?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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: