tags:

views:

72

answers:

2

Hi have built two xmls files that map the content of a given folders:

<root>
    <folder name="C:\a\b" permision="yes" folderCount="1">
        <folders>
            <folder name="C:\a\b\c" permision="yes" folderCount="1">
                <folders>
                    <folder name="C:\a\b\c\e" permision="yes" folderCount="0">
                <folders/>
                <files>
                    <file name="401-1.htm"/>
                    <file name="401-2.htm"/>
                    <file name="401-3.htm"/>                              
                </files>
            </folder>
            <folder name="C:\a\b\d" permision="yes" folderCount="0">
                <folders/>
                <files>
                    <file name="401-4.htm"/>
                    <file name="401-5.htm"/>
                    <file name="401-3.htm"/>                                
                </files>
            </folder>
        </folders>
        <files/>
    </folder>
</root>

I'd like to know if there is a way to find the difference between the files

(since one file is the old state and the second is the new state and its only possible to add files and not remove them- It would be great to remove identical nodes from the new state so only the new files will be left)

+3  A: 

I would use LINQ to XML like the project below:

Diff in XML files with LINQ:
http://www.codeproject.com/KB/linq/LinqDiff.aspx

atconway
+1 The project is unfinished... yet very interesting. I'll see if I can use it to compare my xml files. Thanks.
Asaf
+1  A: 

If you'd like to do it in code, you could use Microsoft'ss XML Diff and Patch GUI Tool, and although there isn't a great deal of documentation, there is enough that you should be able to easily diff two XML files in code, in a fairly short space of time. I use it in a couple of projects as part of a series of unit tests which ensure that XML files are being generated correctly.

If you just want to view the differences between the two files, then you could just use any decent diff tool.

sgrassie
+1 It does exactly what I want, but I prefer to use the main sdk... I really don't want to find out that the patch is not supported by future sdk's. Another thing it has bugs that should be fixed before you can enjoy it.... The good news are that what I want to do is done-able both in essence and in time (less then a second for 435KB files). Thanks very much Asaf
Asaf