XML.ReadFile
------------

Reads a file as XML.

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

MBS( "XML.ReadFile"; Path { ; Flags } ) 

**MBS**( **"XML.ReadFile";** /\* Reads a file as XML. \*/  
**$Path**; /\* The file path or URL to read as XML file.e.g. "/Users/cs/Desktop/test.xml" \*/   
**$Flags**) /\* Optional; Various Flags.  
Add 1 to ignore errors in xml and continue parsing. This may lead to not everything in the xml being read.  
Add 8 to remove all namespaces before query to have queries easier.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Path | The file path or URL to read as XML file. | "/Users/cs/Desktop/test.xml" |  |
| Flags | Various Flags.   Add 1 to ignore errors in xml and continue parsing. This may lead to not everything in the xml being read.   Add 8 to remove all namespaces before query to have queries easier. | 0 | Optional |

### Result

Returns XML reference or error.

### Description

Reads a file as XML.  
The document stays in memory and can be queried several times as needed.  
If you need to query a lot of values, please parse once first. Else all [XML](component_XML.md) functions need to parse again on each call.  
Not limited in file size, so you can read in giga byte big files if you have free memory.  
Please use [XML.Release](XMLRelease.md) later to free document from memory.  
  
By passing XML directly from file content to XML engine, we avoid any corruption due to wrong encoding or line endings.  
  
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

Read XML file:

 $xmlRef = MBS ( "XML.ReadFile"; "/Users/cs/Desktop/iTunes Library.xml")  
### See also

- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [XML.Release](XMLRelease.md)

### Release notes

- **Version 7.4**
    - Added [XML.ReadContainer](http://www.mbsplugins.eu/XMLReadContainer.shtml) and [XML.ReadFile](http://www.mbsplugins.eu/XMLReadFile.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 7.4pr7](https://www.mbsplugins.de/archive/2017-09-21/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2025, Seite 20](https://filemaker-magazin.de/neuigkeit/4290-Appetithappen-FMM_202503)

This function checks for a license.

Created 17th September 2017 , last changed 17th September 2017

  
[XML.ReadContainer](XMLReadContainer.md) - [XML.Release](XMLRelease.md)

[HTML Version](XMLReadFile.shtml)