zoukankan      html  css  js  c++  java
  • DELPHI中调用XSD去验证XML的合法性

    procedure TFrmPrintReport.Button3Click(Sender: TObject);
    var
      SchemaDoc, XmlDoc: IXMLDOMDocument2;
      SchemaCache: IXMLDOMSchemaCollection;
      Error: IXMLDOMParseError;
    begin
        // Load the data
        XmlDoc := CoDOMDocument40.Create;
        XmlDoc.async := False;
        XmlDoc.load('D:RONGXING旅客登记IIReportAir2007-11-20SA_0711200845_ZYK.xml');
        // Load the schema doc
        SchemaDoc := CoDOMDocument40.Create;
        SchemaDoc.async := False;
        SchemaDoc.load(ExtractFilePath(Application.Exename) +'testsmanifest.xsd');
        // Register the schema with the cache
        SchemaCache := CoXMLSchemaCache40.Create;
        SchemaCache.add('', schemadoc);
        // Assign the schema cache to the document
        XmlDoc.schemas := schemacache;
        // Validate and report
        Error := xmldoc.validate;
        if Error.errorCode <> S_OK then
          Memo1.Lines.Add(Error.reason)
        else
          Memo1.Lines.Add('验证成功');   
    end;

  • 相关阅读:
    编程这几天出现的很2的问题!!!
    2020 8 1 每日总结
    2020 8 6 每日总结
    2020 8 7 读后感
    2020 8 4 每日总结
    2020 7 30 每日总结
    2020 8 3 每日总结
    2020 8 8 每日总结
    2020 8 2 每周总结
    2020 8 5 每日总结
  • 原文地址:https://www.cnblogs.com/mikemao/p/3455243.html
Copyright © 2011-2022 走看看