November 2003
Intermediate to advanced
476 pages
14h 38m
English
Since XmlDiffPatch is a
.NET assembly, it can be included in any .NET project by adding it as
a reference in Visual Studio .NET, or by specifying the
/r:xmldiffpatch.dll command-line switch to the C#
compiler. If you plan to use XmlDiffPatch in
multiple projects, you may find it useful to add it to your Global
Assembly Cache using the installutil
executable or the Microsoft .NET Framework Configuration
tool.
Once
you’ve added the XmlDiffPatch
reference to your project or Makefile, you can include it in your own
source code with the using statement:
using Microsoft.XmlDiffPatch;
Example 13-1 shows a program which constructs two
XmlDocument instances in memory, then compares
them using XmlDiff.
using System; using System.Text; using System.Xml; using Microsoft.XmlDiffPatch; public class DoDiff { public static void Main(string [ ] args) { XmlDocument doc1 = new XmlDocument( ); doc1.AppendChild(doc1.CreateXmlDeclaration("1.0", null, null)); doc1.AppendChild(doc1.CreateElement("foo")); XmlDocument doc2 = new XmlDocument( ); doc2.AppendChild(doc2.CreateXmlDeclaration("1.0", null, null)); doc2.AppendChild(doc2.CreateElement("bar")); doc2.DocumentElement.AppendChild(doc2.CreateElement("baz")); XmlTextWriter diffgram = new XmlTextWriter(Console.Out); diffgram.Formatting = Formatting.Indented; XmlDiff diff = new XmlDiff(XmlDiffOptions.None); diff.Compare(doc1, doc2, diffgram); diffgram.Flush( ...