locked
XMLDiff for Framework 4.0? RRS feed

  • Question

  • I've used XMLDiff frequently in my unit tests of code that creates/manipulates XML; however I'm concerned that the library will not work in the 4.0 .Net Framework. Is that in fact an issue and, if so, will there be an updated build appropriate for that framework?

    This utility has been invaluable and I'd really hate to have to do without!

    Bill
    Bill Cohagan
    Thursday, February 4, 2010 8:52 PM

Answers

  • Hello Bill,

    Based on my test, we can still use the XMLDiff tool in .NET 4.0 Framework.

    In my test, I install the xmldiffpatch.exe tool C":\Program Files (x86)\XmlDiffPatch". Then, in my Visual Studio 2010, .NET 4.0 project, I can reference the dll "C:\Program Files (x86)\XmlDiffPatch\Bin\xmldiffpatch.dll" and use Classes from the assembly,

    I use the following codes to test with your xml template and actual, and get this output,
    ------------------------------------------
            static void Main(string[] args)
            {
                XmlWriter output = XmlWriter.Create("output.xml");
                Microsoft.XmlDiffPatch.XmlDiff xmlDiff = new Microsoft.XmlDiffPatch.XmlDiff(
                    Microsoft.XmlDiffPatch.XmlDiffOptions.IgnoreComments);
                xmlDiff.Compare("template.xml", "actual.xml", false, output);
                output.Close();
            }
    ------------------------------------------

    ------------------------------------------
      <?xml version="1.0" encoding="utf-8" ?>
    - <xd:xmldiff version="1.0" srcDocHash="13827802614965761504" options="IgnoreComments" fragments="no" xmlns:xd="http://schemas.microsoft.com/xmltools/2002/xmldiff">
    - <xd:node match="2">
    - <xd:node match="1">
    - <xd:node match="1">
      <xd:add>foo</xd:add>
      </xd:node>
      </xd:node>
    - <xd:node match="2">
    - <xd:node match="1">
      <xd:add>bar</xd:add>
      </xd:node>
      </xd:node>
    - <xd:node match="3">
      <xd:change match="@msg">dynamic</xd:change>
    - <xd:node match="1">
      <xd:add>blob</xd:add>
      </xd:node>
      </xd:node>
      </xd:node>
      </xd:xmldiff>
    ------------------------------------------

    So could you please recheck it.


    Best regards,
    Ji Zhou
    MSDN Subscriber Support in Forum
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bill Cohagan Saturday, February 6, 2010 5:28 PM
    Friday, February 5, 2010 5:39 AM
    Moderator
  • It should work with .NET Framework 4.0. In addition the package you download should contain sources so if you want/need you should be able to compile it with 4.0 compiler.

    Pawel
    • Marked as answer by Bill Cohagan Saturday, February 6, 2010 5:28 PM
    Friday, February 5, 2010 11:42 PM
    Moderator

All replies

  • Hello Bill,

    Based on my test, we can still use the XMLDiff tool in .NET 4.0 Framework.

    In my test, I install the xmldiffpatch.exe tool C":\Program Files (x86)\XmlDiffPatch". Then, in my Visual Studio 2010, .NET 4.0 project, I can reference the dll "C:\Program Files (x86)\XmlDiffPatch\Bin\xmldiffpatch.dll" and use Classes from the assembly,

    I use the following codes to test with your xml template and actual, and get this output,
    ------------------------------------------
            static void Main(string[] args)
            {
                XmlWriter output = XmlWriter.Create("output.xml");
                Microsoft.XmlDiffPatch.XmlDiff xmlDiff = new Microsoft.XmlDiffPatch.XmlDiff(
                    Microsoft.XmlDiffPatch.XmlDiffOptions.IgnoreComments);
                xmlDiff.Compare("template.xml", "actual.xml", false, output);
                output.Close();
            }
    ------------------------------------------

    ------------------------------------------
      <?xml version="1.0" encoding="utf-8" ?>
    - <xd:xmldiff version="1.0" srcDocHash="13827802614965761504" options="IgnoreComments" fragments="no" xmlns:xd="http://schemas.microsoft.com/xmltools/2002/xmldiff">
    - <xd:node match="2">
    - <xd:node match="1">
    - <xd:node match="1">
      <xd:add>foo</xd:add>
      </xd:node>
      </xd:node>
    - <xd:node match="2">
    - <xd:node match="1">
      <xd:add>bar</xd:add>
      </xd:node>
      </xd:node>
    - <xd:node match="3">
      <xd:change match="@msg">dynamic</xd:change>
    - <xd:node match="1">
      <xd:add>blob</xd:add>
      </xd:node>
      </xd:node>
      </xd:node>
      </xd:xmldiff>
    ------------------------------------------

    So could you please recheck it.


    Best regards,
    Ji Zhou
    MSDN Subscriber Support in Forum
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bill Cohagan Saturday, February 6, 2010 5:28 PM
    Friday, February 5, 2010 5:39 AM
    Moderator
  • It should work with .NET Framework 4.0. In addition the package you download should contain sources so if you want/need you should be able to compile it with 4.0 compiler.

    Pawel
    • Marked as answer by Bill Cohagan Saturday, February 6, 2010 5:28 PM
    Friday, February 5, 2010 11:42 PM
    Moderator
  • Thanks for running the experiment (which I should have done rather than assuming the worst!)

    Bill


    Bill Cohagan
    Saturday, February 6, 2010 5:28 PM
  • Pawel
      Thanks for the response -- and for pointing out that the source is in the download. I hadn't noticed that!

    Bill
    Bill Cohagan
    Saturday, February 6, 2010 5:28 PM