Imports System.Xml.Linq
Imports System.Collections.Generic
Public Sub CompareXMLs()
Dim xmlFile1 As String = “C:\Users\dravula\Downloads\EFTORD_deeProd4 (4).xml”
Dim xmlFile2 As String = “C:\Users\dravula\Downloads\EFTORD_ee11 (4).xml”
Dim doc1 As XDocument = XDocument.Load(xmlFile1)
Dim doc2 As XDocument = XDocument.Load(xmlFile2)
Dim differences As New List(Of String)()
If XNode.DeepEquals(doc1.Root, doc2.Root) Then
Console.WriteLine("The XML files are identical.")
Else
Console.WriteLine("The XML files are different.")
FindDifferences(doc1.Root, doc2.Root, "", differences)
End If
Console.WriteLine("Differences:")
For Each difference As String In differences
Console.WriteLine(difference)
Next
End Sub
Private Sub FindDifferences(element1 As XElement, element2 As XElement, path As String, ByRef differences As List(Of String))
If Not IsEqual(element1, element2) Then
differences.Add(path)
End If
For Each child1 As XElement In element1.Elements()
Dim child2 As XElement = element2.Element(child1.Name)
If child2 IsNot Nothing Then
FindDifferences(child1, child2, path & "/" & child1.Name.LocalName, differences)
Else
differences.Add(path & "/" & child1.Name.LocalName)
End If
Next
End Sub
Private Function IsEqual(element1 As XElement, element2 As XElement) As Boolean
If element1.Name <> element2.Name Then
Return False
End If
If element1.Value <> element2.Value Then
Return False
End If
If Not element1.HasAttributes AndAlso Not element2.HasAttributes AndAlso Not element1.HasElements AndAlso Not element2.HasElements Then
Return True
End If
If element1.HasAttributes <> element2.HasAttributes Then
Return False
End If
If element1.HasAttributes Then
If element1.Attributes().Count() <> element2.Attributes().Count() Then
Return False
End If
For Each attr1 As XAttribute In element1.Attributes()
Dim attr2 As XAttribute = element2.Attribute(attr1.Name)
If attr2 Is Nothing OrElse attr1.Value <> attr2.Value Then
Return False
End If
Next
End If
If element1.HasElements <> element2.HasElements Then
Return False
End If
If element1.HasElements Then
If element1.Elements().Count() <> element2.Elements().Count() Then
Return False
End If
Dim child1 As IEnumerator(Of XElement) = element1.Elements().GetEnumerator()
Dim child2 As IEnumerator(Of XElement) = element2.Elements().GetEnumerator()
While child1.MoveNext() AndAlso child2.MoveNext()
If Not IsEqual(child1.Current, child2.Current) Then
Return False
End If
End While
End If
Return True
End Function
ERRORS for this code are unable to solve these errors.
Error Validation Error No compiled code to run
error BC30026: ‘End Sub’ expected. At line 0
error BC30024: Statement is not valid inside a method. At line 1
error BC30024: Statement is not valid inside a method. At line 2
error BC30289: Statement cannot appear within a method body. End of method assumed. At line 4
error BC30429: ‘End Sub’ must be preceded by a matching ‘Sub’. At line 93 Workflow2.xaml
can anyone help this out