XML.Compact
-----------

Compacts XML document.

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

MBS( "XML.Compact"; XML; Flags ) 

**MBS**( **"XML.Compact"** /\* Compacts XML document. \*/  
**$XML**; /\* The XML to process.  
Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time. e.g. "&lt;test&gt;Hello&lt;/test&gt;" \*/   
**$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.  
Add 64 to skip prefix line with xml version. e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| XML | The XML to process.   Can be XML as text or the reference returned by [XML.Parse](XMLParse.md) function, so you can make several times changes to the XML without parsing it each time. | "&lt;test&gt;Hello&lt;/test&gt;" |
| 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.   Add 64 to skip prefix line with xml version. | 0 |

### Result

Returns XML text or error.

### Description

Compacts XML document.  
Removes spaces and returns to make compact representation to save network bandwidth for transmitting or disk space for storage.  
### Examples

Compact the document:

 MBS ("XML.Compact"; XML::Input XML; 1)  
Compact document without prefix:

 MBS ("XML.Compact"; "&lt;a&gt;Test&lt;/a&gt;"; 1+64)  
<small>  
Example result: &lt;a&gt;Test&lt;/a&gt;</small>### See also

- [XML.Format](XMLFormat.md)
- [XML.Parse](XMLParse.md)

### Release notes

- **Version 15.1**
    - Improved [XML.Canonical](https://www.mbsplugins.eu/XMLCanonical.shtml), [XML.Compact](https://www.mbsplugins.eu/XMLCompact.shtml), [XML.Format](https://www.mbsplugins.eu/XMLFormat.shtml) and [XML.Colorize](https://www.mbsplugins.eu/XMLColorize.shtml) functions to return empty text for empty output.
- **Version 13.0**
    - Added new option to [XML.Compact](https://www.mbsplugins.eu/XMLCompact.shtml) and [XML.Format](https://www.mbsplugins.eu/XMLFormat.shtml) to skip the ?xml line with version details.
- **Version 10.2**
    - Added [XML.Compact](https://www.mbsplugins.eu/XMLCompact.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 15.1pr1](https://www.mbsplugins.de/archive/2025-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.6pr1](https://www.mbsplugins.de/archive/2022-12-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [News about the MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-19/News_about_the_MBS_FileMaker_P/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 10.2](https://www.mbsplugins.de/archive/2020-05-12/Neues_MBS_FileMaker_Plugin_102/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.2 - More than 6200 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-05-12/MBS_FileMaker_Plugin_102_-_Mor/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr6](https://www.mbsplugins.de/archive/2020-05-04/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

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

This function checks for a license.

Created 27th April 2020 , last changed 28th November 2022

  
[XML.Colorize](XMLColorize.md) - [XML.DeletePath](XMLDeletePath.md)

[HTML Version](XMLCompact.shtml)