13.3 Microsoft.XmlDiffPatch Namespace Reference
The
Microsoft.XmlDiffPatch namespace contains classes
which allow you to compare two XML documents. You can use the
XmlDiff class to produce a third XML document,
called an XML Difference Language (XDL) Diffgram, which lists the
differences between the source documents, and you can use the
XmlPatch class to recreate the changed document.
You can specify details of how the differences are computed using the
XmlDiffOptions and
XmlDiffAlgorithm enumerations.
XmlDiff | Microsoft.XmlDiffPatch (xmldiffpatch.dll) class |
public class XmlDiff {
// Public Constructors
public XmlDiff( );
public XmlDiff( XmlDiffOptions options);
// Public Static Fields
public const string NamespaceUri; // =http://schemas.microsoft.com/xmltools/2002/xmldiff
// Public Instance Fields
public XmlDiffPerf _xmlDiffPerf;
// Public Instance Properties
public XmlDiffAlgorithm Algorithm{set; get; }
public bool IgnoreChildOrder{set; get; }
public bool IgnoreComments{set; get; }
public bool IgnoreDtd{set; get; }
public bool IgnoreNamespaces{set; get; }
public bool IgnorePI{set; get; }
public bool IgnorePrefixes{set; get; }
public bool IgnoreWhitespace{set; get; }
public bool IgnoreXmlDecl{set; get; }
public XmlDiffOptions Options{set; }
// Public Static Methods
public static XmlDiffOptions ParseOptions( string options);
public static bool VerifySource( System.Xml.XmlNode node, ulong hashValue, XmlDiffOptions options);
// Public Instance Methods
public bool Compare( string sourceFile, string changedFile, bool bFragments);
public bool Compare( string sourceFile, string changedFile, bool bFragments, System.Xml.XmlWriter diffgramWriter);
public bool Compare( System.Xml.XmlNode sourceNode, System.Xml.XmlNode changedNode);
public bool Compare( System.Xml.XmlNode sourceNode, System.Xml.XmlNode changedNode, System.Xml.XmlWriter diffgramWriter);
public bool Compare( System.Xml.XmlReader sourceReader, System.Xml.XmlReader changedReader);
public bool Compare( System.Xml.XmlReader sourceReader, System.Xml.XmlReader changedReader,
System.Xml.XmlWriter diffgramWriter);
} | |
This type is used to generate
an XML Difference Language Diffgram which describes the differences
between two XML documents. The constructor takes an optional
XmlDiffOptions argument, which specifies which XML
node types may be ignored. Each XmlDiffOptions
value may also be specified by one of the properties
IgnoreChildOrder,
IgnoreComments, IgnoreDtd,
IgnoreNamespaces, IgnorePI,
IgnorePrefixes,
IgnoreWhitespace, and
IgnoreXmlDecl, as well as through the
Options property. The algorithm used to compute
the Diffgram may be specified by setting the
Algorithm property. The Compare(
) method is used to actually compute the Diffgram and write
it to a System.Xml.XmlWriter. The input XML
documents may be specified as URIs,
System.Xml.XmlNodes, or
System.Xml.XmlReaders. You can specify a
System.Xml.XmlWriter to output the Diffgram to.
Compare( ) returns true if the
input documents are equal.
XmlDiffAlgorithm | Microsoft.XmlDiffPatch (xmldiffpatch.dll) serializable enum |
public enum XmlDiffAlgorithm {
Auto = 0,
Fast = 1,
Precise = 2
} | |
This enumeration is used to specify
the comparison algorithm for the XmlDiff class.
For a quick but imprecise comparison, use Fast.
For a more precise but slower comparison using the Zhang-Shasha
algorithm, use Precise. To have
XmlDiff make a best guess as to the best
algorithm, based on document size, use Auto.
Auto is the default value.
Hierarchy
System.Object
System.ValueType
System.Enum(System.IComparable, System.IFormattable,
System.IConvertible)
XmlDiffAlgorithm
Returned By
XmlDiff.Algorithm
Passed To
XmlDiff.Algorithm
XmlDiffOptions | Microsoft.XmlDiffPatch (xmldiffpatch.dll) serializable enum |
public enum XmlDiffOptions {
None = 0,
IgnoreChildOrder = 1,
IgnoreComments = 2,
IgnorePI = 4,
IgnoreWhitespace = 8,
IgnoreNamespaces = 16,
IgnorePrefixes = 32,
IgnoreXmlDecl = 64,
IgnoreDtd = 128
} | |
This enumeration is used to specify
whether the XmlDiff class should ignore certain
types of nodes when computing differences.
Hierarchy
System.Object
System.ValueType
System.Enum(System.IComparable, System.IFormattable,
System.IConvertible)
XmlDiffOptions
Returned By
XmlDiff.ParseOptions( )
Passed To
XmlDiff.{Options, VerifySource(
), XmlDiff( )}
XmlPatch | Microsoft.XmlDiffPatch (xmldiffpatch.dll) class |
public class XmlPatch {
// Public Constructors
public XmlPatch( );
// Public Instance Methods
public void Patch( string sourceFile, System.IO.Stream outputStream, System.Xml.XmlReader diffgram);
public void Patch( System.Xml.XmlDocument sourceDoc, System.Xml.XmlReader diffgram);
public void Patch( refSystem.Xml.XmlNode sourceNode, System.Xml.XmlReader diffgram);
public void Patch( System.Xml.XmlReader sourceReader, System.IO.Stream outputStream, System.Xml.XmlReader diffgram);
} | |
This type is
used to recreate a changed XML document by applying the XML
Difference Language Diffgram generated by XmlDiff
to the original document.
|