Solved

Compare xml node by node

Posted on 2008-10-21
4
1,100 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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