combobox1 中显示 xml 内容 求 C#代码
<?xmlversion="1.0"encoding="gb2312"?><ShowList><Movie><user>admin</user><password>adm...
<?xml version="1.0" encoding="gb2312"?>
<ShowList>
<Movie>
<user>admin</user>
<password>admin</password>
</Movie>
<Movie>
<user>aaaa</user>
<password>2222</password>
</Movie>
<Movie>
<user>ww</user>
<password>wwww</password>
</Movie>
</ShowList>
只显示user的值
xml的路径为@"Data\dlfile.xml" 展开
<ShowList>
<Movie>
<user>admin</user>
<password>admin</password>
</Movie>
<Movie>
<user>aaaa</user>
<password>2222</password>
</Movie>
<Movie>
<user>ww</user>
<password>wwww</password>
</Movie>
</ShowList>
只显示user的值
xml的路径为@"Data\dlfile.xml" 展开
2015-09-06 · 知道合伙人软件行家
关注
展开全部
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)
}
}
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)
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询