cmb_State_Send.ItemsSource = null;
XmlDocument doc = new XmlDocument();
doc.Load("D:\\模板\\WorkstationState_Config.xml"); //加载Xml文件
XmlElement rootElem = doc.DocumentElement; //获取根节点
XmlNode xn = rootElem.SelectSingleNode("//Workstation[@Name=‘" + str + "‘]");
if (xn != null)
{
XmlNodeList xn1 = xn.ChildNodes;
List<string> tem = new List<string>();
for (int i = 0; i < xn1.Count; i++)
{
tem.Add(xn1.Item(i).InnerText);
}
if (tem.Count > 0)
{
cmb_State_Send.ItemsSource = tem;
cmb_State_Send.SelectedIndex = 0;
}
}
读取XML文件的指定节点的值 并转换为Item,布布扣,bubuko.com
时间: 2024-10-11 06:13:49