将XML节点加载到列表框中 [英] Loading XML Nodes Into A Listbox

查看:91
本文介绍了将XML节点加载到列表框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我已经在线查看了如何将XML节点添加到列表框中,但我很难挣扎。这是我到目前为止的代码。



Basically, I have looked online for how to add XML Nodes to a list box but im struggling. This is the code of what i have so far.

XmlDocument doc = new XmlDocument();
doc.LoadXml(XMLPath);

XmlNodeList nodeList = doc.SelectNodes("/Names/Name");

foreach (XmlNode xn in listBox1.Items)
{

}





想要将下面所有的XML节点加载到列表框中



名字/姓名/第一



我会喜欢这方面的帮助,因为它会是非常接受



im wanting to load all the XML nodes with this below into the listbox

Names/Name/First

I would love some help on this please, as it would be greatly recieved

推荐答案

想一想:你在写什么?!想一想:

Just think a bit: what are you writing?! Think about this:
foreach(var item in nodeList)
   myListBox.Items.Add(SomethingBasedOnYourNode(item));   





但请记住,您不必在列表框中存储字符串。通常,您希望存储一些数据。请参阅我以前的回答: combobox.selectedvalue在winform中显示{} [< a href =http://www.codeproject.com/Answers/541683/combobox-selectedvalueplusshowsplus-7b-7dplusinplu#answer1target =_ blanktitle =New Window> ^ ]。



你明白了吗?



-SA


这篇关于将XML节点加载到列表框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆