Selecting the Algorithm for the Comparison

Microsoft XML Diff

Microsoft XML Diff 1.0 and XML Patch 1.0

Selecting the Algorithm for the Comparison

The XmlDiff class has implemented two algorithms for comparing XML documents:

  • XmlDiffAlgorithm.Precise: Based on an algorithm for finding editing distance between trees, also known as Zhang-Shasha algorithm. This algorithm gives very precise results but it may be very slow on large XML documents with many changes.
  • XmlDiffAlgorithm.Fast: Compares the two XML documents by traversing the XML tree and comparing each node. This algorithm is very fast, but may produce less precise results. For example, it may detect an xd:add and xd:remove operation on a node instead of a change operation. The Fast algorithm is as accurate as the Precise algorithm. For example, the results in the XDL Diffgram are a non-empty XDL Diffgram whenever the files are different, and the algorithm will produce an empty XDL Diffgram when the files are equivalent, with regard to the options set.
  • XmlDiffAlgorithm.Auto: Chooses the comparison algorithm for you depending on the size and assumed number of changes in the compared documents.

To select the comparison algorithm you want to use, set the Algorithm property of the XmlDiff class before calling Compare. The default value of this property is XmlDiffAlgorithm.Auto.

For more information, see XmlDiffAlgorithm Enumeration.

See Also

XML Diff Functionality | Running Comparisons Between Documents, Fragments, or Nodes | Setting Options that Affect the Comparison | Limitations | XML Diff Language (Diffgram) | Extended Operations | Example of a Diffgram | XmlDiff Class

© 2002 Microsoft Corporation. All rights reserved.