Skip to Content
.NET & XML
book

.NET & XML

by Niel M. Bornstein
November 2003
Intermediate to advanced
476 pages
14h 38m
English
O'Reilly Media, Inc.
Content preview from .NET & XML

Using the XmlDiffPatch Namespace

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.

Example 13-1. Program to construct and compare two XmlDocument instances
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( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Applied XML Programming for Microsoft® .NET

Applied XML Programming for Microsoft® .NET

Dino Esposito
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0596003978Supplemental ContentErrata