xmlValidate

Uses a Document Type Definition (DTD) or XML Schema to validate an XML text document or an XML document object. Returns keys status (boolean), errors (array), fatalerrors (array) and warnings (array)

xmlValidate(xmlDoc [, validator]) → returns struct

Argument Reference

xmlDoc any
Required

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.

validator string

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 this argument is omitted the XML document must have a !DOCTYPE xsi:schemaLocation or xsi:noNamespaceSchemaLocation tag pointing to the DTD or schema location.

Links more information about xmlValidate

Examples
Sample code invoking the xmlValidate function

Validates that note.xml is valid according to the schema note.xsd. Not currently working on Lucee, see: LDEV-2909

xmlValidate("https://www.w3schools.com/xml/note.xml", "https://www.w3schools.com/xml/note.xsd").status

Expected Result: true

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub