Treeview nodes question

dakota97

Centurion
Joined
Nov 14, 2003
Messages
116
Location
Pennsylvania
Hi all,

I'm having problems building the hierarchy of a treeview control from an XML file. I'm basically looking to replicate the same structure that the Windows registry uses (HKEY_Local_Machine/Software/....etc.), but I can't figure out how to build the tree so that I don't duplicate childnodes.

Our tech support team receives XML files with various infomormation retrieved from the end-user's computer. They use this to diagnose hardware compatibility issues with our software, since a lot of it is low-level communication with the hardware. However, it is painstakingly time consuming to read the raw XML that is produced. So, I've been assigned the task of creating a "Support Reader" application that will load the XML file into a "human readable" format.

Ultimately, the application will parse the XML file, and create the tree structure. Then when the user clicks on a specific node, the underlying values will be populated in a listbox or listview control, the same way as seen when navigating through the Windows registry.

So far, I've been able to insert the top-level nodes (all the HKEY ones), and one childnode, but I'm having major difficulties adding additional nodes below that. The big thing is that if the node exists, I don't want to add it a second time.

I've attached the XML file template that I'm using, and would appreciate any pointers or code samples on how I can get this to work.

Thanks in advance,

Chris
 

Attachments

Thanks Machaira for the reply, and sample.

I had a problem opening the solution file, saying that it was missing 3 files. But, I was able to successfully convert you VB code into C# and get the sample working. The only problem I see (and it was probably my fault for not being more clear in my explanation) is that when drilling down through the tree, it places the "HKEY_LOCAL_MACHINE/Software/E-Prime......." as a string value at the lowest level. What I'm looking to do is parse that string, and build the tree according to the values.

I guess a better way to explain it would be I need to retrieve that string from the "RegistryKey" node. Then I need to insert the "HKEY_LOCAL_MACHINE" as the first node in the treeview. Then add the "Software" as a childnode to that...."E-Prime" as a child nose to "Software"...etc. Then, I'll need to grab the next "RegistryKey" value, and do the same, only without duplicating the childnodes. So somehow I need to check and see if the childnode already exists (which I can see that you code does do), and if it does go to the next part of the string.

Thanks for the effort, and if that explains it any better, let me know any ideas or suggestions.

Thanks,

Chris
 
Back
Top