Solved

Compare xml node by node

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 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