2

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.

2
  • I'm guessing you still get duplicates in your treeview? Commented May 13, 2010 at 6:58
  • ya. ur right. I came to know that we can use xelement instead of xdocument. please help if u can Commented May 13, 2010 at 12:21

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.