none
xml diff patch in vb with framework 2.0 or 3.5 RRS feed

  • Question

  • Good morning

    I am looking for the functionality described in this article (for .net 1.0) in either framework 2.0 or 3.5, to be implemented using vb.

    article: http://msdn.microsoft.com/en-us/vcsharp/ee957397.aspx

    I've been looking around for a few days, and asked on stackoverflow.com with no luck.
    http://stackoverflow.com/questions/2057955/saving-and-restoring-xml-differences

    The xml diff/patch behavior would be so useful, I can't believe it was scrapped totally.

    My situation is that I have a large xml that is a 'template' then a large number of user specific versions containing user specific modifications to that 'template'.
    I want to save the delta between the template and the user specific modified version only, rather than saving the whole template for each user.
    Saving the whole template for each user requires saving of alot of redundant info, is hard to scale, and smells bad.
    I like the xml diff/patch described in the article above because it is generic and wouldn't require any awareness of structural changes to the xml.

    Thanks for any ideas or help.
    • Moved by Ji.ZhouModerator Wednesday, January 20, 2010 8:52 AM XML question (From:Visual Basic Language)
    Tuesday, January 19, 2010 1:12 PM

Answers

  • Hello Todd.c

    Yes, I did some researches on this. What I find is, although there is not a new version of the XML Diff and Patch tool. But we still can download the 1.0version from,
    http://download.microsoft.com/download/xml/Patch/1.0/WXP/EN-US/xmldiffpatch.exe

    And we can still use the tool in our project.

    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 you should also be able to use the XML Diff and Patch tool in your .NET 2.0 project


    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.
    Friday, January 29, 2010 5:55 AM
    Moderator
  • Hello Todd,

    Have you tried to use the tool's assembly directly from your .NET 2.0 or above project. It should work fine. If you have any further questions or concerns on this, please let me know and I will try my best to follow up.


    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 todd.c Thursday, February 11, 2010 7:57 PM
    Tuesday, February 2, 2010 4:55 AM
    Moderator

All replies

  • Hello,

    I am moving this thread to XML and .NET Framework for better discussions.

    And the first MSDN link you post seems wrong. I read your posts in stackover and copy the right one as follows,
    http://msdn.microsoft.com/en-us/library/aa302294.aspx

    I am reviewing and researching this topic. I will post if I get further ideas.

    Best regards,
    Ji Zhou

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, January 20, 2010 9:32 AM
    Moderator
  • Hi Ji Zhou

    It's been over a week.. Have you had any luck with your research?


    Thursday, January 28, 2010 12:33 PM
  • Hello Todd.c

    Yes, I did some researches on this. What I find is, although there is not a new version of the XML Diff and Patch tool. But we still can download the 1.0version from,
    http://download.microsoft.com/download/xml/Patch/1.0/WXP/EN-US/xmldiffpatch.exe

    And we can still use the tool in our project.

    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 you should also be able to use the XML Diff and Patch tool in your .NET 2.0 project


    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.
    Friday, January 29, 2010 5:55 AM
    Moderator
  • Hello Todd,

    Have you tried to use the tool's assembly directly from your .NET 2.0 or above project. It should work fine. If you have any further questions or concerns on this, please let me know and I will try my best to follow up.


    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 todd.c Thursday, February 11, 2010 7:57 PM
    Tuesday, February 2, 2010 4:55 AM
    Moderator
  • Thanks Ji Zhou

    This works perfectly.
    Thursday, February 11, 2010 7:58 PM