Neuronring R

Neuronring R

  • NA
  • 10
  • 1.9k

How to Load Tree Views into Dictionaries/hash Tables for Com

Aug 11 2014 2:59 PM
Hi All,
 
I am stuck up with Tree Comparison problem. I have two TreeViews. treeView1 and treeView2.

I wrote a program to compare two treeviews recursively and highlight the differences which compares the "text" of the nodes side by side and highlights the difference.

Let me summarize.....

1) Go to Tree1, read the node text,
2) Compare it with the node text of Tree2
3) if not equals, HIGHLIGHT COLOR...
4) Traverse recursively to all the child nodes and do a side by side comparison as mentioned in step 2 and step 3

.....But Now I figured out that wont be a good comparison.

This method will be helpful only for side by side comparison of two trees' "text" data.

If the Nodex in Tree 1 is present in Tree 2 also, but at a different level, not at the same place as in Tree 1 this will end up showing false mismatch.

Example:

<Disk Drive>C:</Disk Drive> is present in both the trees but at different positions.
My AIM is to ONLY check if <Disk Drive>C:</Disk Drive> present in both the trees or XMLs. Doesn't matter if they are ordered.

In a real time scenario.

I am loading the Trees with XML file from Two different computers.

XML 1 has the data from Computer 1 with all the list of installed software.

XML 2 has data from Computer 2 with all the list of installed software.

I am loading these into two Trees,

But the list from both the computer may not have the same order of data.

The "Microsoft Office" can be listed as Node2 in Tree1 and the same can be present as Node10 in Tree2
How would I overcome this situation. Can you please advice..???


How can I compare two Trees to check if all the data in the Tree 1 exists in Tree 2 no matter in which order the nodes are located.
Please advice.

I am thinking of Dictionaries to implement this, But but not sure how to load Tree View into Dictionaries and use it for comparison recursively.
 

sically I am getting System Configuration of two systems, Machine-1 and Machine-2 in individual XML files.

Such as BIOS_Machine1.xml, Installed_Softwares_machine1.xml, Windows_Updates_Machine_1.xml

BIOS_Machine2.xml, Installed_Softwares_machine2.xml, Windows_Updates_Machine_2.xml

Similarly I am extracting the same type of information from Machine2 as XML files.

I can compare the two XML files using xmldiff. But I need to show the output in a tree by visually highlighting the difference. That is why i went with treeview. From the XMLs, irrespective of which level of node the item appears. For example, I just need to find if "Microsoft Outlook" is present in XML of Machine2. In Installed_Softwares_machine1.xml it might be first in the list, but Installed_Softwares_machine2.xml it can be the 10th item. but the XMLDIFF still considers this as a diff when it is actually not. I understand it is because of the XML data format.

<Configuration>
<DisplayName>Microsoft Office Outlook MUI (English) 2010</DisplayName>
<DisplayVersion>14.0.6029.1000</DisplayVersion>
<InstallDate>20140630</InstallDate>
<Publisher>Microsoft Corporation</Publisher>
</Configuration>

as long as the software is present in both the nodes it is not a difference.

If the "Microsoft Office" is present in the Installed_Softwares_machine2.xml, then the other properties like DisplayVersion,InstallDate,Publisher needs to be compared.