问题描述
我正在使用c#.net windows表单应用程序。我有一个包含许多节点的xml文件。一些节点具有相同的名称。我想在树视图中显示这些节点。为此,我认为将所有节点名称放入列表中。比较节点是否已退出
并仅在树视图中显示唯一名称。我的xml文件如下:
<?xml version =" 1.0"编码= QUOT; UTF-8英寸?>
- < languages>
- < language>
< key> abc< / key>
< value>你好怎么ru< / value>
< / language>
- < language>
< key> def< / key>
< value>我很好< / value>
< / language>
- < language>
< key> ghi< / key>
< value> abt u< / value>
< / language>
< / languages>
这里我只需要显示:
语言
语言
键
值。
Im using c#.net windows form application. I have a xml file that contains many nodes. Some nodes have same names. I want to display these nodes in a tree view. For that what i think is to get all node names into a list. Compare if the node already exits and display only unique names into a tree view.My xml file is given below:
<?xml version="1.0" encoding="utf-8" ?>
- <languages>
- <language>
<key>abc</key>
<value>hello how ru</value>
</language>
- <language>
<key>def</key>
<value>i m fine</value>
</language>
- <language>
<key>ghi</key>
<value>how abt u</value>
</language>
</languages>
Here i need to display only:
languages
language
key
value.
同样,如果有任何其他节点具有不同的名称,我需要显示它们。
请帮帮我。
Similarly if there are any other nodes with different names, I need to display them
Please help me.
推荐答案
我也不确定为什么同时提及列表和树视图。树视图是分层的,列表是平的。至于您要查找的唯一名称,这是否适用于整个文档?或者只对每个元素的子元素?
I am also not sure why are mentioning both a list and a tree view. A tree view is hierarchical, a list is flat. As for the unique names you want to find, does that apply to the whole document? Or only to the child elements of each element?
这篇关于使用c#将xml文件中的唯一节点名称添加到列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!