Good morning, I need to validate an XML against its XSD (parsing); I use Delphi 7 on a Win7 Virtualbox machine. I have found examples and explanations in Internet. I have chosen this example that is seemed me simple and proper:
procedure TForm1.Button1Click(Sender: TObject);
var XML, XSDL: Variant;
begin
XSDL := CreateOLEObject('MSXML2.XMLSchemaCache.4.0');
XSDL.validateOnLoad := True;
XSDL.add('','C:\Lavoro\Fattura_Elettronica_PRIVATI\Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd');
ShowMessage('Schema Loaded');
XML := CreateOLEObject('MSXML2.DOMDocument.4.0');
XML.validateOnParse := True;
XML.resolveExternals := True;
XML.schemas := XSDL;
XML.load(Edit1.Text);
ShowMessage(XML.parseError.reason);
end;
But the "CreateOLEObject" function raise an exception class EOleSysError with message "interface string not valid" (translated by italian). In uses clause I've inserted "OleCtnrs, ComObj, xmldom, XMLIntf, msxmldom, XMLDoc, MSXML2_TLB". Why this exception? Thanks for your answer.