Solved

Compare xml node by node

Posted on 2008-10-21
4
1,098 Views
Last Modified: 2013-12-17
Hi all,

I have 2 xml strings which will have the same elements and nodes..One is called OldValue and the other is NewValue. What I want to do is compare the 2 xml and see which nodes are different. Below is my 2 xml.We can see that the Specification node value is different (OldValue = 137650.9900 - NewValue = 137650.0000)

How can I compare these 2 xml and store the node or nodes that may be different?
//----------OldValue----------

<?xml version="1.0" encoding="utf-16"?><PhaseLabourCosts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><MachineType>E</MachineType><Planning>93000.0000</Planning><Specification>137650.9900</Specification><Design>664250.0000</Design><Construction>393700.0000</Construction><Installation>996000.0000</Installation></PhaseLabourCosts>
 

//----------NewValue----------

<?xml version="1.0" encoding="utf-16"?><PhaseLabourCosts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><MachineType>E</MachineType><Planning>93000.0000</Planning><Specification>137650.0000</Specification><Design>664250.0000</Design><Construction>393700.0000</Construction><Installation>996000.0000</Installation></PhaseLabourCosts>

Open in new window

0
Comment
Question by:caoimhincryan
  • 2
4 Comments
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22765283
you might need to use XSLT for this. check the below link:
http://www.dpawson.co.uk/xsl/sect2/N1777.html
 
0
 

Author Comment

by:caoimhincryan
ID: 22765316
>> SameerJagdale - Is that link relevant to C# code?
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22765336
caoimhincryan:
will tell you how to create .xsl file.
0
 
LVL 25

Accepted Solution

by:
apeter earned 500 total points
ID: 22770129
1. Load the xmls in two diff xmldocument.
2. Get the RootElement of above 2
3. Loop through based on childnodes count
4. take action if a particular node is not equal
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now