出自:http://stackoverflow.com/questions/446635/schema-validation-with-msxml-in-delphi

uses MSXML2_TLB  
That is:  
// Type Lib: C:\Windows\system32\msxml4.dll
// LIBID: {F5078F18-C551-11D3-89B9-0000F81FE221}

function TfrmMain.ValidXML(
    const xmlFile: String; const xsdFile: String;
    out err: IXMLDOMParseError): Boolean;
var
    xml, xsd: IXMLDOMDocument2;
    cache: IXMLDOMSchemaCollection;
begin
    xsd := CoDOMDocument40.Create;
    xsd.Async := False;
    xsd.load(xsdFile);

    cache := CoXMLSchemaCache40.Create;
    cache.add('http://the.uri.com/schemalocation', xsd);

    xml := CoDOMDocument40.Create;
    xml.async := False;
    xml.schemas := cache;

    Result := xml.load(xmlFile);
    if not Result then
      err := xml.parseError
    else
      err := nil;
end;

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2021-07-11
  • 2021-12-29
  • 2022-12-23
猜你喜欢
  • 2022-01-27
  • 2022-12-23
  • 2021-08-07
  • 2021-12-03
  • 2021-07-20
相关资源
相似解决方案