Muthu Kumar

Muthu Kumar

  • NA
  • 4
  • 2.6k

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

Mar 31 2012 3:23 AM
i have to receive a mail when compare 2 xml files difference

i have 2 xml file

1 st xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Books>
<Book bookId="100" name="Asp.Net" price = "230" />
<Book bookId="101" name="C#" price = "200" />
<Book bookId="102" name="Silverlight" price = "300" />
<Book bookId="103" name="MFC Book" price = "300" />
</Books>


2 nd xml file:


<?xml version="1.0" encoding="utf-8" ?>
<Books>
<Book bookId="100" name="Asp.Net" price = "230" />
<Book bookId="101" name="C#" price = "200" />
<Book bookId="102" name="Silverlight" price = "300" />
<Book bookId="104" name="WPF" price = "200" />
<Book bookId="105" name="WCF" price = "200" />
</Books>






first of all i need to compare this 2 xml files

if there is any changes between these Xml Files
i need to receive an E-mail alert . received E-mail should be like this
for (ex)

inserted 2 id
<Books>
<Book bookId="104" name="WPF" price = "200" />
<Book bookId="105" name="WCF" price = "200" />
</Books>

Deleted 1 id
<Book bookId="103" name="MFC Book" price = "300" />


This is my coding, but it's not exactly what i was loooking for

Dim description, filepath
Dim xmlDoc1 = CreateObject("Msxml2.DOMDocument")
xmlDoc1.load("D:406tree.xml") 'file 1
Dim xmlDoc2 = CreateObject("Msxml2.DOMDocument")
xmlDoc2.load("D:406tree_en.xml") 'file 2
Dim ElemList1 = xmlDoc1.DocumentElement.ChildNodes
Dim ElemList2 = xmlDoc2.DocumentElement.ChildNodes
If ElemList1.length = ElemList2.length Then ' check weather both xml file has same number of childnodes
MsgBox("Both XML files have same number of Child nodes")


For i = 0 To ElemList1.length - 1


If ElemList1.item(i).Text = ElemList2.item(i).Text Then
MsgBox("child element:" & i & " is same in both XML files")
Else
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)



End If


Next
End If




is it possible?
i am new to c#
pls help me some 1?