Validating XML documents

ColdFusion provides the following methods for validating a document against a DTD or an XML Schema:

  • The XmlParse function can validate XML text that it is parsing against a DTD or Schema. It the function encounters a validation error, ColdFusion generates an error and stops parsing the text. If the validator generates warnings, but no errors, ColdFusion parses the document and returns the result.
  • The XmlValidate function can validate an XML text document or XML document object. against a DTD or Schema. The function returns a data structure with detailed information from the validator, including arrays of warning, error, and fatal error messages, and a Boolean status variable indicating whether the document is valid. Your application can examine the status information and determine how to handle it further.
    For examples of XML validation, see XmlParse and XmlValidate in the CFML Reference. The XmlParse example validates a document using a DTD. The XmlValidate example validates the document using an XML Schema that represents the same document structure as the DTD.
Adobe logo

Sign in to your account