i have to receive a mail when compare 2 xml files difference

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
i have to receive a mail when compare 2 xml files difference<br/>
<br/>
<br/>
i have 2 xml file <br/>
<br/>
<br/>
1 st xml file:<br/>
<?xml version="1.0" encoding="utf-8" ?><br/>
<Books><br/>
<Book bookId="100" name="Asp.Net" price = "230" /><br/>
<Book bookId="101" name="C#" price = "200" /><br/>
<Book bookId="102" name="Silverlight" price = "300" /><br/>
<Book bookId="103" name="MFC Book" price = "300" /><br/>
</Books><br/>
<br/>
<br/>
<br/>
<br/>
2 nd xml file:<br/>
<br/>
<br/>
<br/>
<br/>
<?xml version="1.0" encoding="utf-8" ?><br/>
<Books><br/>
<Book bookId="100" name="Asp.Net" price = "230" /><br/>
<Book bookId="101" name="C#" price = "200" /><br/>
<Book bookId="102" name="Silverlight" price = "300" /><br/>
<Book bookId="104" name="WPF" price = "200" /><br/>
<Book bookId="105" name="WCF" price = "200" /><br/>
</Books><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
first of all i need to compare this 2 xml files<br/>
<br/>
<br/>
if there is any changes between these Xml Files<br/>
i need to receive an E-mail alert . received E-mail should be like this <br/>
for (ex)<br/>
<br/>
<br/>
inserted 2 id<br/>
<Books><br/>
<Book bookId="104" name="WPF" price = "200" /><br/>
<Book bookId="105" name="WCF" price = "200" /><br/>
</Books><br/>
<br/>
<br/>
Deleted 1 id<br/>
<Book bookId="103" name="MFC Book" price = "300" /><br/>
<br/>
<br/>
<br/>
<br/>
This is my coding, but its not exactly what i was loooking for <br/>
<br/>
<br/>
Dim description, filepath<br/>
Dim xmlDoc1 = CreateObject("Msxml2.DOMDocument")<br/>
xmlDoc1.load("D:406tree.xml") file 1<br/>
Dim xmlDoc2 = CreateObject("Msxml2.DOMDocument")<br/>
xmlDoc2.load("D:406tree_en.xml") file 2<br/>
Dim ElemList1 = xmlDoc1.DocumentElement.ChildNodes<br/>
Dim ElemList2 = xmlDoc2.DocumentElement.ChildNodes<br/>
If ElemList1.length = ElemList2.length Then check weather both xml file has same number of childnodes <br/>
MsgBox("Both XML files have same number of Child nodes")<br/>
<br/>
<br/>
<br/>
<br/>
For i = 0 To ElemList1.length - 1<br/>
<br/>
<br/>
<br/>
<br/>
If ElemList1.item(i).Text = ElemList2.item(i).Text Then<br/>
MsgBox("child element:" & i & " is same in both XML files")<br/>
Else<br/>
MsgBox("child element:" & i & " is not same in both XML files, In XML file 1, The value is:" & ElemList1.item(i).Text & " and In XML file 2, The value is:" & ElemList2.item(i).Text)<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
End If<br/>
<br/>
<br/>
<br/>
<br/>
Next<br/>
End If<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
is it possible?<br/>
i am new to .Net<br/>
pls help me some 1?

View the full article
 
Back
Top