Uses a Document Type Definition (DTD) or XML Schema to validate an XML text document or an XML document object.


The following validation structure:




An array containing any validator error messages. These messages indicate that the document does not conform to the DTD or Schema (is not valid).


An array containing any validator fatal error messages. Fatal errors indicate that the document contains XML formatting errors (is not well-formed XML).


A Boolean value:

  • True if the document is valid.
  • False if the validation check failed.


An array containing any validator warnings. A well-formed and valid document can produce warning messages.


XML functions

Function syntax

XmlValidate(xml, [validator])

See also

cfxmlIsXmlDocIsXMLXmlFormatXmlNewXmlParseXmlSearchXmlTransformUsing XML and WDDX in the Developing ColdFusion Applications


ColdFusion (2018 release): Introduced named parameters.

ColdFusion MX 7: Added this function.





Any of the following:

  • A string containing an XML document.
  • The name of an XML file.
  • The URL of an XML file; valid protocol identifiers include http, https, ftp, and file.
  • An XML document object, such as one generated by the XmlParse function.


Any of the following:

  • A string containing a DTD or Schema.
  • The name of a DTD or Schema file.
  • The URL of a DTD or Schema file; valid protocol identifiers include http, https, ftp, and file.


If you specify a relative URL or filename in a parameter, ColdFusion uses the directory (or, for URLs, the virtual directory) that contains the current ColdFusion page as the path root. The validator parameter specifies a DTD or Schema to use to validate the document. If you omit the parameter, the XML document must contain one of the following:

  • A !DOCTYPE tag to specify the DTD or its location
  • An xsi:schemaLocation or xsi:noNamespaceSchemaLocation tag to specify the Schema location
    If you use a validator parameter and the XML document specifies a DTD or Schema, the XmlValidate function uses the validator parameter, and ignores the specification in the XML document.If you do not use a validator parameter, and the XML document does not specify a DTD or Schema, the function returns a structure with an error message in the Errors field.This function attempts to process the complete XML document, and reports all errors found during the processing. As a result, the returned structure can have a combination of Warning, Error, and FatalError fields, and each field can contain multiple error messages.


The following example has three parts: an XML file, an XSD Schema file, and a CFML page that parses the XML file and uses the Schema for validation. The CFML file displays the value of the returned structure's Status field and displays the returned structure. To show the results of invalid XML, modify the custorder.xml file.

Note: The Schema used in the following example represents the same XML structure as the DTD used in the XmlParse example.

The custorder.xml file is as follows:

<?xml version="1.0" encoding="UTF-8"?> 
<order xmlns:xsi="" xsi:noNamespaceSchemaLocation="http://localhost:8500/something.xsd" id="4323251" > 
<customer firstname="Philip" lastname="Cramer" accountNum="21"/> 
<item id="43"> 
<name> Deluxe Carpenter&apos;s Hammer</name> 
<item id="54"> 
<name> 36&quot; Plastic Rake</name> 
<item id="68"> 
<name> Standard paint thinner</name> 

The custorder.xsd file is as follows:

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema xmlns:xs="" 
<xs:element name="customer"> 
<xs:attribute name="firstname" type="xs:string" use="required"/> 
<xs:attribute name="lastname" type="xs:string" use="required"/> 
<xs:attribute name="accountNum" type="xs:string" use="required"/> 
<xs:element name="name" type="xs:string"/> 
<xs:element name="quantity" type="xs:string"/> 
<xs:element name="unitprice" type="xs:string"/> 
<xs:element name="item"> 
<xs:element ref="name"/> 
<xs:element ref="quantity"/> 
<xs:element ref="unitprice"/> 
<xs:attribute name="id" type="xs:integer" use="required"> 
<xs:element name="items"> 
<xs:element ref="item" maxOccurs="unbounded"/> 
<xs:element name="order"> 
<xs:element ref="customer"/> 
<xs:element ref="items"/> 
<xs:attribute name="id" type="xs:string" use="required"/> 

The CFML file is as follows. It uses a filename for the XML file and a URL for the Schema. The XML and URL paths must be absolute.

Did custorder.xml validate against custorder.xsd? #myResults.status#<br><br> 
Dump of myResults structure returned by XMLValidate<br> 
<cfdump var="#myResults#">