Click here to Skip to main content
15,905,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 XML file.
First XML file:
XML
<?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>

Second XML file:
XML
<?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 these two XML files.
If there is any difference between these XML files I need to receive an E-mail alert.
The received E-mail should be like this for example:
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 the result is not exactly what I was looking for.
VB
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 child nodes
            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 . Net
Please help me someone?
Posted
Updated 30-Mar-12 23:25pm
v3
Comments
André Kraak 31-Mar-12 5:00am    
Edited question:
Added pre tags
Formatted text/code
Spelling/Grammar
Replaced txt speak
OriginalGriff 31-Mar-12 5:16am    
Um.
How to put this.
Your tag is C#.
You interest is C#: "Is it possible? I am new to C#. Please help me someone?"

But your code is VB.
What are you trying to do, exactly?
Use the "Improve question" widget to edit your question and provide better information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900