🆕validateXML
To validate XML documents against an XSD schema
The validateXML
function checks whether a given XML string conforms to the rules defined by an XSD schema. It reads the schema from a file attached to a record and returns a JSON object containing the validation result and any errors found.
This function is especially useful for validating data received from external sources, such as web services or APIs, ensuring data integrity before further processing.
Caution: If the file doesn't contain a valid XSD schema, the function returns void
.
Syntax
validateXML(record, xmlText, xsdFilename)
Parameters
record: The source record containing the attached XSD schema file.
xmlText: The XML string to validate.
xsdFilename: The name of the XSD schema file attached to the record.
Return
JSON: A JSON object containing the validation result (true
or false
) and any errors encountered during validation.
Examples
1. Validate XML string
Result:
2. Invalid XML string
Result:
See also
formatJSON
, which creates a JSON string of a valid JSON object.
parseXML
, which converts an XML string to a JSON object.
formatXML
, which converts a given JSON object into XML text, which might be optically structured.
Last updated