Innovative XML solutions since 2003

ExamXML  MDCXML  JExamXML  xml2csv  csv2xml 
CompareXML
MDCXML provides API for using XML comparison functionality within user's application
written on C, C++, C# .NET. Delivery package includes DLL mdcxml.dll and header file
XMLComparator.h than should be included in source code. To use mdcxml.dll it
should be included to PATH environment variable.

int CompareXML(
    LPCTSTR firstXmlFile,
    LPCTSTR secondXmlFile,
    LPCTSTR outputXmlFile,
    UINT outputFileMode,
    LPCTSTR optionsFile
);

firstXmlFile
 [in] The name of the first XML file to compare

secondXmlFile
 [in] The name of the second XML file to compare

outputXmlFile
 [in] The name of output XML file to created. If this parameter is NULL or empty string
 no output file will be created and function returns only result of comparison

outputFileMode
 [in] Mode of output XML file
Symbol ValueDigital ValueMeaning
ID_SAVE_DIFF980Save Differences between two XML files
ID_MERGE981Merge two XML files
ID_SAVE_COMM_TAGS982Save Common XML elements from the first XML file
ID_SAVE_DIFF_TAGS983Save Only Different XML elements from the first XML file
ID_SAVE_DEL_TAGS984Save Only Deleted XML elements from the first XML file
ID_SAVE_DEL_AND_DIFF_TAGS985Save Both Deleted and Different XML elements from the first XML file

optionsFile
 [in] The name of option's file. If this parameter is NULL or empty string default options will be used.

Return Value

  • 0 Two files are identical
  • 1 There are some different elements
  • 2 There are some deleted elements
  • 3 Parameters Error occurred (please check all required parameters)
  • 4 Options Error occurred (options file specified but not found or not correct)
  • 5 XML File Error occurred (xml file not found)
  • 6 XML Parser Error occurred (xml file not correct)
  • Remarks

    MDCXML prints errors and result of comparison to console screen (default) and/or to Message Box.
    There are two options in the option file that set printing device
    PrintResultToScreen  MDCXML prints errors and result to Console Screen
                             (useful for console application)
    PrintResultToWindow  MDCXML prints errors and result to Message Box
                             (useful for Window's application)
    
    To switch off any messages and turn MDCXML in silent mode set both options to 0.
    
    
    

     Header : Declared in XMLComparator.h
     DLL : Requires mdcxml.dll
     Unicode : Implemented as CompareXMLW (Unicode) and CompareXMLA (ANSI).
     Examples
     C++:

    #include <Windows.h>
    #include <tchar.h>
    #include "XMLComparator.h"
    
    int _tmain(int argc, _TCHAR* argv[]) {
        int retval = -1;
        HINSTANCE hinstLib = LoadLibrary(MDCXML_LIB);
        if (hinstLib) {
            COMPAREXMLPROC proc = (COMPAREXMLPROC) GetProcAddress(hinstLib, MDCXML_PROC);
            if (proc) {
                retval = (proc)(_T("test1.xml"),
                                _T("test2.xml"),
                                _T("out.xml"),
                                ID_SAVE_DIFF,
                                _T("options"));
            }
            FreeLibrary(hinstLib);
       }
       return retval;
    }
    

     C#:
    using System;
    using System.Runtime.InteropServices;
    
    class Examxml {
        [DllImport("mdcxml.dll", CharSet=CharSet.Unicode)]
        static extern long CompareXMLW(String xmlfile1,
                                       String xmlfile2,
                                       String outfile,
                                       uint mode,
                                       String optionsfile);
        public static void Main() {
            Examxml.CompareXMLW("first.xml", "second.xml", "diff.xml", 980, "");
        }
    }
    

     Python:
    from ctypes import *
    windll.mdcxml.CompareXMLW(u'first.xml',u'second.xml',u'diff.xml',980,u'options')
    windll.mdcxml.CompareXMLA('first.xml','second.xml','diff.xml',980,'options')
    

     VB.NET:
    Public Declare Function CompareXMLA Lib "mdcxml.dll" (ByVal xmlfile1 As String, ByVal xmlfile2 As String, ByVal outfile As String, ByVal mode As Long, ByVal optionfile As String) As Long
    
    Public Sub Main()
    	CompareXMLA("struts.xml","struts2.xml","d32.xml",980,"")
    End Sub
    
    

     VB:
    <DllImport("mdcxml.dll")> _
    Private Shared Sub CompareXMLA(ByVal xmlfile1 As String, _
                                   ByVal xmlfile2 As String, _
                                   ByVal outfile As String, _
                                   ByVal mode As Long, _
                                   ByVal optionfile As String) As Integer
    End Sub