combobox1 中显示 xml 内容 求 C#代码

2024-12-19 03:34:51
推荐回答(1个)
回答1:

string xmlFilePath = @"D:\Data\dlfile.xml";
XmlDocument doc = new XmlDocument();
doc.Load(xmlFilePath);

//使用xpath表达式选择文档中所有的student子节点
XmlNodeList studentNodeList = doc.SelectNodes("//Movie/user");
if (studentNodeList != null)
{
foreach (XmlNode studentNode in studentNodeList)
{
combobox1.items.add(studentNode.value)
}

}