Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9141573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:39:45+00:00 2026-06-17T09:39:45+00:00

At this moment, I am managing a piece of software that has multiple XML

  • 0

At this moment, I am managing a piece of software that has multiple XML configuration files. When a new version of software is released, sometimes the base config files change, we currently have the software call KDiff on startup. If it detects a change, it prompts the user to choose the changes.

The problem with this approach is that KDiff is a line comparing program and not aware of the ways of XML (like Nodes, etc.)

Ideally, I would like to programmatically work with a library in C# (since we’re a MS shop) that can Diff two XML files: a Source XML and a Current Working XML.

And then Merge the two together using a few simple rules:

  1. If the Current Working XML has a node that the Source XML does not, remove it.
  2. If the Source XML has a node that the Current Working XML does not, add it.
  3. If both have the same node and the values differ, favor the Source XML’s value, unless it the Source XML’s value is set to “UseExistingValue”.

For example, here’s the “Source” XML:

<Configuration>
  <Items>
     <Item Id="1" Position="true">
       <Location X="UseExistingValue" Y="UseExistingValue" Z="UseExistingValue" />

       <Something/>
       <SomethingElse/>
     </Item>
   </Items>
 </Configuration>

And here’s the “Current Working” XML:

<Configuration>
  <Items>
    <Item Id="1" Position="false">
      <Location X="123" Y="234" Z="345" />
      <Another/>
      <Something/>

    </Item>
  </Items>
</Configuration>

And the merged version would look like:

<Configuration>
  <Items>
    <Item Id="1" Position="true">
      <Location X="123" Y="234" Z="345" />

      <Something/>
      <SomethingElse/>
    </Item>
  </Items>
</Configuration>

I’ve looked at the MS XML Diff and Patch Tool and it definitely merges the files together, but doesn’t allow for the programmatic rules that I want to define.

XMLUnit for Java devs seems promising, but the .NET version of it seems underdeveloped, which is unfortunate.

Anyone have any suggestions for either scriptable XML Diff/Merge tools and/or .NET libraries (paid or free)?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:39:46+00:00Added an answer on June 17, 2026 at 9:39 am

    After a couple days of messing around, I found a solution that I think works for me. Maybe it could work for other people as well.

    The MS XML Diff and Patch tool was a viable option. When you Diff first file against the second file it creates an XML “DiffGram” listing what changes it detected between the two XML files.

    To take care of all 3 rules that I listed above, I Diff’d the two files in one direction, then opened the DiffGram file using Linq-to-XML and Removed all the “Add” and “Remove” lines.

    XNamespace xd = "http://schemas.microsoft.com/xmltools/2002/xmldiff";
    var doc = XDocument.Load(_diffGramFile);
    doc.Root.DescendantsAndSelf(xd + "add").Remove();
    doc.Root.DescendantsAndSelf(xd + "remove").Remove();
    

    Then I patched up (merged) this edited diffgram against the first file and created a partially merged temporary file. This takes care of Rules 1 and 2.

    Next, I Diff’d the partially merged file against the first file used. Then opened the new DiffGram and removed all Change references to “UseExistingValue”.

    var newdoc = XDocument.Load(_diffGramFile);
    newdoc.Root.DescendantsAndSelf(xd + "change")
          .Where(x => x.Value == "UseExistingValue").Remove();
    

    And merged this edited DiffGram against the partially merged file which takes care of Rule 3. Saving this out to XML then produces the final XML merged according to the rules defined above.

    Hopefully this can help out other people.

    HINT: After installing the XmlDiffPatch library, the XmlDiffPatch DLL can be found in C:\Windows\assembly\GAC\XmlDiffPatch\1.0.8.28__b03f5f7f11d50a3a\XmlDiffPatch.dll

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At this moment we are building a new architecture that is based on the
We have a database that contains xml fields. At this moment we perform queries
This is what I have at the moment. <h2>Information</h2>\n +<p>(.*)<br />|</p> ^ that is
At this moment there is a very basic flash project that connects to a
At this moment I'm using a simple checksum scheme, that just adds the words
At this moment I have 2 project that use the same content directory (scripts,
i am learning java at this moment and i've read somewhere that i can
Till this moment I used this method to invoke: public string AddText { set
So at this moment (but most likely not for long) Reddit, Meetup, Fark, LinkedIn,
Up to this moment I was using simple arrays to enter and get necessary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.