Populate tree with xml file using c #
Im using a C # .net form application. I have an xml file containing nodes. I need to populate a treeview with nodes present in an XML file. Also avoid duplicate node names. For this, my idea is to populate a treeview, copy the node names into the list and see if node exits. If it already exits, go to the next node else to display it. List listOfNodes = new list ();
listOfNodes.Add (xNode.Name.ToString ()); // if (! (listOfNodes.Contains (xNode.Name.ToString ())))
I tried to deal with it. but I cannot do it. Please suggest me the correct code.
a source to share
I suggest taking a look at some examples of xml binding to TreeView using XmlDataProvider and HierarchicalDataTemplate . As the example in the XmlDataProvider documentation shows, the key for displaying the node name is to use it Path="Name"
instead XPath
in the binding.
a source to share