How to get specific error code with MSXML SAX validator

2025-05-04T09:58:09.22+00:00
When I use MSXML DOM model for validating a XML file against a schema, I get validation error "0xc00ce014" for XML structural issues. Now, we need to use MSXML SAX model for validating XML file as its very big. Using this model we always get error code "0x80004005" for any type of error. So, how do I get same functionality as earlier (i.e need to differentiate this error). AI models suggesting me to parse the error message as this is a known issue. But, if I know all kinds of error messages then I can put a map. How do I get those messages?
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,935 questions
{count} votes

Accepted answer
  1. RLWA32 48,746 Reputation points
    2025-05-07T20:08:17.2533333+00:00

    But, if I know all kinds of error messages then I can put a map. How do I get those messages?

    MSXML6 uses a resource only dll (MSXML6r.dll) for messages. I used the following console application on Win 10 22H2 to print the message table.

    #define WIN32_LEAN_AND_MEAN
    #include <Windows.h>
    
    #include <stdio.h>
    #include <tchar.h>
    
    int _tmain()
    {
        auto hModule = LoadLibraryEx(_T("C:\\Windows\\System32\\msxml6r.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE);
        if (hModule)
        {
            HRSRC hrsrc = FindResource(hModule, MAKEINTRESOURCE(1), RT_MESSAGETABLE );
            if (hrsrc)
            {
                HGLOBAL hglobal = LoadResource(hModule, hrsrc);
                if (hglobal)
                {
                    PVOID pv = LockResource(hglobal);
                    if (pv)
                    {
                        PMESSAGE_RESOURCE_DATA pmrd = (PMESSAGE_RESOURCE_DATA)pv;
                        _tprintf_s(_T("Message resource data contains %u blocks\n"), pmrd->NumberOfBlocks);
                        for (DWORD i = 0; i < pmrd->NumberOfBlocks; i++)
                        {
                            PMESSAGE_RESOURCE_BLOCK pmrb = &pmrd->Blocks[i];
                            _tprintf_s(_T("\n--------- Block %u -----------\n"), i);
                            _tprintf_s(_T("LowId: %u, HighId: %u, OffsetToEntries: %u\n"), pmrb->LowId, pmrb->HighId, pmrb->OffsetToEntries);
                            for (DWORD x = pmrb->LowId, y = 0; x <= pmrb->HighId; x++)
                            {
                                LPTSTR pszText{};
                                FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS,
                                    hModule, x, 0, (LPTSTR)&pszText, 0, nullptr);
                                _tprintf_s(_T("Message id: %u (0x%08X), Text: %s\n"), x, x, pszText);
                                LocalFree(pszText);
                            }
                        }
                        UnlockResource(hglobal);
                    }
                }
            }
    
            FreeLibrary(hModule);
        }
        return 0;
    }
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. nallandighal, srinivas (TR Technology) 20 Reputation points
    2025-05-13T20:40:09.0733333+00:00

    It worked. Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.