Jump to content
Sign in to follow this  
AndrewHoward

validate XML against XSD

Recommended Posts

Hi,

This code validates XML against XSD but it returns the first error.

 How can I make it return all erros in XML in one go ?

 

Thank you.

function TXmlValidator.ValidateXml(const XmlFileName: string; const SchemaCollection: IXMLDOMSchemaCollection2): Boolean;
var
  XmlDocument: IXMLDOMDocument3;
  parseError: IXMLDOMParseError;
begin
  XmlDocument := TmsxmlFactory.CreateXMLDOMDocument3WithValidateOnParseFromFile(XmlFileName);
  XmlDocument.schemas := SchemaCollection;


  parseError := XmlDocument.validate();
  FValidationResult := TXMLDOMParseErrorToString.ToString(parseError);

  Result := ValidationResult = NullAsStringValue;;
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×