0
votes

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.

1
Use a pure delphi library for xml parsing - David Heffernan

1 Answers

0
votes

What is the actual error code? If it is 0x800401F3 (CO_E_CLASSSTRING) the message is "Invalid class string", instead of "Interface string not valid". My guess is that MSXML4 is not installed on your computer. It is old, use MSXML6 instead.