XmlDiff.Compare Method (String, String, Boolean, XmlWriter)
Performs a comparison of XML documents or fragments and outputs an XDL Diffgram describing the differences.
[Visual Basic] Overloads Public Function Compare( _ ByVal sourceFile As String, _ ByVal changedFile As String, _ ByVal bFragments As Boolean, _ ByVal diffgramWriter As XmlWriter _ ) As Boolean [C#] public Boolean Compare( String sourceFile, String changedFile, Boolean bFragments, XmlWriter diffgramWriter );
Parameters
- sourceFile
- A file name or URL containing the original source XML document or fragment to be used in the comparison.
- changedFile
- A file name or URL containing the changed XML document or fragment to be used in the comparison.
- bFragments
- A flag indicating whether the sourceFile and changedFile are well-formed XML documents (false) or whether they are fragments (true).
- diffgramWriter
- The XmlWriter to which you want to output the XDL Diffgram.
Example
[Visual Basic] Imports System Imports System.Xml Imports Microsoft.XmlDiffPatch Namespace TestCompare Class Class1 Shared Sub Main() Dim diffgramWriter = New XmlTextWriter("diffgram.xml", New System.Text.UnicodeEncoding()) Dim xmlDiff As New XmlDiff() Dim bSame As Boolean = xmlDiff.Compare("Source.xml", "Changed.xml", False, diffgramWriter) diffgramWriter.Flush() diffgramWriter.Close() End Sub End Class End Namespace [C#] using System; using System.Xml; using Microsoft.XmlDiffPatch; namespace TestCompare { class Class1 { static void Main() { XmlWriter diffgramWriter = new XmlTextWriter("diffgram.xml", new System.Text.UnicodeEncoding()); XmlDiff xmlDiff = new XmlDiff(); bool bSame = xmlDiff.Compare("Source.xml", "Changed.xml", false, diffgramWriter); diffgramWriter.Flush(); diffgramWriter.Close(); } } }
For information on running the code samples, see Running XmlDiff and XmlPatch Class Code Samples.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP, Windows .NET Server