MSXML: How to programmatically get error text for failed conversions?

XMLNotepad provides the following text (for example) if the conversion fails:

XML conversion error A
variable or parameter "rich background-color" was duplicated with the same import precedence.

How can I get this error text programmatically? My code is as follows:

CComPtr<IXSLTemplate> tmpl;
HRESULT hr = CoCreateInstance(CLSID_XSLTemplate, NULL, CLSCTX_INPROC_SERVER, IID_IXSLTemplate, (void**)&tmpl);
if (SUCCEEDED(hr)) {
    hr = tmpl->putref_stylesheet(xslt_doc);
    if (SUCCEEDED(hr)) {
    // Huzzah; do stuff.
    } else {
    // How do I get the error text?  I want to log it!
    }
}
+3
source share
1 answer

If IXSLTemplatesupported IErrorInfo(this is AFAIK), you can request more information.

(jeffamaphone told me the right way to get this - using the GetErrorInfo()API :)

CComPtr<IErrorInfo> error;
if (SUCCEEDED( GetErrorInfo(0, &error) ) && error)
{
   // call IErrorInfo::GetDescription(), etc.
}
+3
source

Source: https://habr.com/ru/post/1704348/


All Articles