Dictionary.ToXML
----------------

Returns XML representation of dictionary for data exchange.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Dictionary](component_Dictionary.md) [XML](component_XML.md) | [6.1](newinversion61.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Dictionary.ToXML"; DictionaryRef { ; Format; RootName } ) 

**MBS**( **"Dictionary.ToXML";** /\* Returns XML representation of dictionary for data exchange. \*/  
**$DictionaryRef**; /\* The reference number to the dictionary.e.g. $dic \*/   
**$Format**; /\* Optional; If 1, we format pretty.  
Pass 0 to get compact xml.e.g. 1 \*/   
**$RootName**) /\* Optional; The root name for the XML.  
Default is dictionary.e.g. "dictionary" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| DictionaryRef | The reference number to the dictionary. | $dic |  |
| Format | If 1, we format pretty.   Pass 0 to get compact xml. | 1 | Optional |
| RootName | The root name for the XML.   Default is dictionary. | "dictionary" | Optional      Added in version **13.2**. |

### Result

Returns text or error.

### Description

Returns XML representation of dictionary for data exchange.  
### Examples

Test exporting dictionaries:

 #   
\#   
\#Create new Dictionary   
\#   
Set Variable \[$param ; Value:MBS ( "[Dictionary.Create](DictionaryCreate.md)" )\]  
\#   
\#Fill in values   
\#   
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "text"; Pass Parameters with Dictionary::TextField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "number"; Pass Parameters with Dictionary::NumberField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "date"; Pass Parameters with Dictionary::DateField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "time"; Pass Parameters with Dictionary::TimeField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "timestamp"; Pass Parameters with Dictionary::TimeStampField )\]  
Set Variable \[$r ; Value:MBS ( "[Dictionary.SetValueForKey](DictionarySetValueForKey.md)"; $param ; "container"; Pass Parameters with Dictionary::ContainerField )\]  
\#   
\#Call save xml, json and text   
\#   
Set Variable \[$r ; Value:MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; MBS ("Dictionary.ToXML"; $param ; 1); MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) ; "dictionary.xml"); "UTF8")\]  
Set Variable \[$r ; Value:MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; MBS ("[Dictionary.ToText](DictionaryToText.md)"; $param ); MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) ; "dictionary.txt"); "UTF8")\]  
Set Variable \[$r ; Value:MBS ( "[Text.WriteTextFile](TextWriteTextFile.md)"; MBS ("[Dictionary.ToJSON](DictionaryToJSON.md)"; $param ); MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ) ; "dictionary.json.txt"); "UTF8")\]  
\#   
\#free memory   
\#   
Set Variable \[$r ; Value:MBS ("[Dictionary.Release](DictionaryRelease.md)"; $param )\]  
### See also

- [Dictionary.Count](DictionaryCount.md)
- [Dictionary.Create](DictionaryCreate.md)
- [Dictionary.Release](DictionaryRelease.md)
- [Dictionary.SetValueForKey](DictionarySetValueForKey.md)
- [Dictionary.ToJSON](DictionaryToJSON.md)
- [Dictionary.ToText](DictionaryToText.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Text.WriteTextFile](TextWriteTextFile.md)

### Release notes

- **Version 13.2**
    - Added root name parameter to [Dictionary.ToXML](https://www.mbsplugins.eu/DictionaryToXML.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 13.2pr2](https://www.mbsplugins.de/archive/2023-04-13/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Data structures in FileMaker with MBS Plugins](https://www.mbsplugins.de/archive/2017-10-19/Data_structures_in_FileMaker_w/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.1pr3](https://www.mbsplugins.de/archive/2016-02-25/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

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

This function checks for a license.

Created 25th February 2016 , last changed 11st April 2023

  
[Dictionary.ToText](DictionaryToText.md) - [Dictionary.ValueForKey](DictionaryValueForKey.md)

[HTML Version](DictionaryToXML.shtml)