Compare two XML files and store the changes

Peterg001

Member
Joined
Aug 5, 2010
Messages
10
Programming Experience
1-3
Afternoon,

Some background info for you. I have two XML Files. The first being an initial capture of a databases tables, columns (including names and datatype). The second is the same but taken 30 minutes later.

My obective is to compare these two files to see what changes, if any, have been made to the databases tables and columns, store each change and then email these changes to an administrator for review.

For example say my two XML files are the ones below:

XML 1

VB.NET:
<dataset>
<table name="BIN">
<column name="POL_EXP_DATE" type="DATE"></column>
<column name="POL_CANC_DATE" type="DATE">
</table>
<table name="TITLE_MRC">
<column name="FORM_NAME" type="VARCHAR2">
</table>
</dataset>

XML 2 (generated 30mins later)

VB.NET:
<dataset>
<table name="BINS">
<column name="POL_EXP_DATE" type="DATE"></column>
<column name="POL_CANC_DATE" type="DATE">
</table>
<table name="TITLE_MRC">
<column name="FORM_NAME" type="VARCHAR2">
</table>
</dataset>

What I want the code I create to do is to go through each element and check it against the other. So in the samples above it would return the fact the first table name has changed to 'BINS' from 'BIN'. It would then continue through the document storing any further differences it finds. This would then be stored in a string perhaps which I can format so its not just one line of characters.

I would then email these difference but I know how to do that bit.

I cant get my head round how I would do that so would appreciate any help.

Thanks
 
I do believe I've advised you already of 2 better ways to do this than your current approach.. ?
 
I thought my previous psts were about getting data out of the database and storing it in an XML file.

Ive done that now. Im trying to compare the two files and get back the changes.

XML Diff does work but it litterally brings back the changes. It doesnt say what the values were before. I would like something in the email to say:

Table "BIN" has been renamed to "BINS"
or
In Table BIN, the datatype for column POL_EXP_DATE has changed from 'Date' to 'Number'
 
Back
Top