Reputation: 673
Im using c#.net windows form application. I have an xml file that contains nodes. I need to populate a treeview with the nodes present in the xml file. Also avoid repeated node names. For this my idea is while populating the treeview, copy the node names into a list and there see if the node already exits. If it already exits, go to the next node else display it. List listOfNodes = new List();
listOfNodes.Add(xNode.Name.ToString()); //if (!(listOfNodes.Contains(xNode.Name.ToString())))
I was trying with this. but Im unable to do. Please suggest me with a proper code.
Upvotes: 2
Views: 1526
Reputation: 5304
I suggest looking at some examples of binding xml to a TreeView using XmlDataProvider and HierarchicalDataTemplate. As the example in XmlDataProvider's documentation shows, the key to showing node name is to use Path="Name"
instead of XPath
in the binding.
Upvotes: 1