EOleException: Microsoft MSXML is not installed when calling LoadXMLDocument
LoadXMLDocument returns IXMLDocument which by default uses MSXML on Windows. MSXML is a COM componet which requires client to initialize COM library. Below shows a bare bones Delphi 11.3 console application initializing COM library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program Project1; | |
{$APPTYPE CONSOLE} | |
{$R *.res} | |
uses | |
ActiveX, | |
ComObj, | |
System.SysUtils, | |
Xml.XMLDoc, | |
Xml.XMLIntf; | |
var | |
XmlDoc: IXMLDocument; | |
begin | |
try | |
try | |
CoInitializeEx(nil, | |
ActiveX.COINIT_MULTITHREADED | |
); | |
XmlDoc := LoadXMLDocument('test.xml'); | |
XmlDoc._Release; | |
XmlDoc := nil; | |
except | |
on E: Exception do | |
Writeln(E.ClassName, ': ', E.Message); | |
end; | |
finally | |
CoUninitialize; | |
end; | |
end. |
No comments:
Post a Comment