在Delphi中用Schema验证XML
出自: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;
-------------------------------------------------
本博客中凡是未标明【转】字样的文章均为原创,作者保留版权,转载请务必保留原文地址。
博客地址:http://xuxn.cnblogs.com
如有问题请联系:[email protected]
本博客中凡是未标明【转】字样的文章均为原创,作者保留版权,转载请务必保留原文地址。
博客地址:http://xuxn.cnblogs.com
如有问题请联系:[email protected]

浙公网安备 33010602011771号