Hi,
I need to compare two XML files in C#. Right now I'm using the XPathNavigator to parse through each node and then compare it with the node present in the other XML. I was able to print the differences. I'm displaying the values from both the XML files in a grid view.
The problem is if I have some extra elements in the two XML files how can I display them.
When an extra element is found in an XML file all the next elements are shown as errors.
Please help me soon.
Thanks in advance.
*************** *************** *************** ***********
Sample XML files I'm using
XML 1
<?xml version="1.0" encoding="UTF-8"?>
<PageTitle>
<Page>
<Id>1</Id>
<Title>This is my testing</Title>
<PageUrl>mybo ok /1/1.aspx</PageUrl>
</Page>
<Page>
<Id>2</Id>
<Title>This is my testing</Title>
<PageUrl> mybook /2/2.aspx</PageUrl>
<new>4</new>
</Page>
<Page>
<Id>3</Id>
<Title>my book</Title>
<test>123</test>
<PageUrl>mybo ok /4/4.aspx</PageUrl>
</Page>
</PageTitle>
XML 2
<?xml version="1.0" encoding="UTF-8"?>
<PageTitle>
<Page>
<Id>12345</Id>
<Title>This is my testing</Title>
<PageUrl>mybo ok /1/1.aspx</PageUrl>
<test>123</test>
</Page>
<Page>
<Id>2</Id>
<Title>This is my testing</Title>
<PageUrl> mybook /2/2.aspx</PageUrl>
<new>4</new>
</Page>
<Page>
<Id>3</Id>
<Title>my book</Title>
<PageUrl>mybo ok /4/4.aspx</PageUrl>
</Page>
</PageTitle>
I need to compare two XML files in C#. Right now I'm using the XPathNavigator to parse through each node and then compare it with the node present in the other XML. I was able to print the differences. I'm displaying the values from both the XML files in a grid view.
The problem is if I have some extra elements in the two XML files how can I display them.
When an extra element is found in an XML file all the next elements are shown as errors.
Please help me soon.
Thanks in advance.
*************** *************** *************** ***********
Sample XML files I'm using
XML 1
<?xml version="1.0" encoding="UTF-8"?>
<PageTitle>
<Page>
<Id>1</Id>
<Title>This is my testing</Title>
<PageUrl>mybo ok /1/1.aspx</PageUrl>
</Page>
<Page>
<Id>2</Id>
<Title>This is my testing</Title>
<PageUrl> mybook /2/2.aspx</PageUrl>
<new>4</new>
</Page>
<Page>
<Id>3</Id>
<Title>my book</Title>
<test>123</test>
<PageUrl>mybo ok /4/4.aspx</PageUrl>
</Page>
</PageTitle>
XML 2
<?xml version="1.0" encoding="UTF-8"?>
<PageTitle>
<Page>
<Id>12345</Id>
<Title>This is my testing</Title>
<PageUrl>mybo ok /1/1.aspx</PageUrl>
<test>123</test>
</Page>
<Page>
<Id>2</Id>
<Title>This is my testing</Title>
<PageUrl> mybook /2/2.aspx</PageUrl>
<new>4</new>
</Page>
<Page>
<Id>3</Id>
<Title>my book</Title>
<PageUrl>mybo ok /4/4.aspx</PageUrl>
</Page>
</PageTitle>
Comment