0

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 .
my 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?

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by thines01
0

1) This sounds like something that should be a console app, not a WinForms app because it reports TO you (so you should not need to prompt it).
2) The System.Xml.Linq namespace would be much better for this than using COM automation.
3) I would imagine (since the files are XML), the ORDER of the elements will not matter.

Will this be set up on a schedule?
What type of mail server are you using?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.