Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Compare xml node by node

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't disable touch pad on Windows 10 computer 16 45
get combo value in class 5 14
Iteration Help (Asp.net VB) 5 24
Syntax Issue with SSIS module 26 103
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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