XML.ValidateFile
----------------

Validates XML against schema.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XML](component_XML.md) | [8.2](newinversion82.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XML.ValidateFile"; FilePath; Schema ) 

**MBS**( **"XML.ValidateFile";** /\* Validates XML against schema. \*/  
**$FilePath**; /\* Native file path to the file to check.e.g. "/Users/cs/Desktop/test.xml" \*/   
**$Schema**) /\* The schema definition as xml text.  
With version 10.2 can also be file path. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| FilePath | Native file path to the file to check. | "/Users/cs/Desktop/test.xml" |
| Schema | The schema definition as xml text.   With version 10.2 can also be file path. | $schema |

### Result

Returns OK or error.

### Description

Validates XML against schema.  
Please pass in XML file path and a valid XSD schema.  
Return list of errors, so you see them all.  
If you use [Process.SetCurrentDirectory](ProcessSetCurrentDirectory.md) to change current folder for the application process, the library uses this folder to search for referenced xsd files.  
  
Changed with version 10.2 that you can pass schema as file name/path, so we can load it from same folder as the schema and referenced files in same folder are found.  
  
If you need more validation, check out [Saxon.Validate](SaxonValidate.md) function.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Validate a file in a folder:

 Set Variable \[ $r ; Value: MBS ( "[Process.SetCurrentDirectory](ProcessSetCurrentDirectory.md)"; "/Users/cs/Documents/todo/XML Validate/") \]   
Set Variable \[ $result ; Value: MBS ("XML.ValidateFile"; "test.xml"; XML Validation::Schema ) \]   
Set Field \[ XML Validation::Result ; $result \]  
Validate all in one folder:

 # set folder   
Set Variable \[ $r ; Value: MBS ( "[Process.SetCurrentDirectory](ProcessSetCurrentDirectory.md)"; "/Users/cs/Desktop/XML Validate") \]   
\#   
\# validate file   
Set Field \[ XML Validation::Result ; MBS ("XML.ValidateFile"; "test.xml"; "generalInvoiceRequest\_450.xsd") \]   
\#   
\# folder contains xmldsig-core-schema.xsd, xenc-schema.xsd, generalInvoiceRequest\_450.xsd and test.xml   
### See also

- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [Process.SetCurrentDirectory](ProcessSetCurrentDirectory.md)
- [Saxon.Validate](SaxonValidate.md)
- [XML.Validate](XMLValidate.md)

### Release notes

- **Version 10.2**
    - Changed [XML.ValidateFile](https://www.mbsplugins.eu/XMLValidateFile.shtml) to accept schema as XML file path.
- **Version 8.2**
    - Added [XML.ValidateFile](http://www.mbsplugins.eu/XMLValidateFile.shtml) function.

### Blog Entries

- [Elektronische Rechnungen in FileMaker mit dem MBS Plugin lokal erzeugen](https://www.mbsplugins.de/archive/2026-09-12/Elektronische_Rechnungen_in_Fi/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr5](https://www.mbsplugins.de/archive/2020-04-27/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 8.2 - More than 5200 Functions In One Plugin](https://www.mbsplugins.de/archive/2018-05-22/MBS_FileMaker_Plugin_82_-_More/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 8.2 - 5200 Funktionen in einem Plugin](https://www.mbsplugins.de/archive/2018-05-22/MBS_FileMaker_Plugin_82_-_5200/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.2pr1](https://www.mbsplugins.de/archive/2018-04-04/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 6th March 2018 , last changed 29th May 2025

  
[XML.Validate](XMLValidate.md) - [ZipFile.CRCFile](ZipFileCRCFile.md)

[HTML Version](XMLValidateFile.shtml)