XML.InsertRecords
-----------------

Imports records from XML file.

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

MBS( "XML.InsertRecords"; XML; Flags; FileName; TableName ) 

**MBS**( **"XML.InsertRecords";** /\* Imports records from XML file. \*/  
**$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 queries 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.e.g. 0 \*/   
**$FileName**; /\* The file name of where the table is inside. Can be empty to look for the table in all files.  
  
Using a table in another database file may require you adding the other file as an external data source and adding the external table to your relationship graph to grant access.e.g. Get(FileName) \*/   
**$TableName**) /\* The name of the table to insert record into.  
If empty, uses name from XML.e.g. "Assets" \*/ 

### 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 queries 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. | 0 |
| FileName | The file name of where the table is inside. Can be empty to look for the table in all files.      Using a table in another database file may require you adding the other file as an external data source and adding the external table to your relationship graph to grant access. | Get(FileName) |
| TableName | The name of the table to insert record into.   If empty, uses name from XML. | "Assets" |

### Result

Returns number or error.

### Description

Imports records from XML file.  
You may need to use various [XML](component_XML.md) functions first to get only the relevant parts of a XML or apply a XLST with [XML.ApplyStylesheet](XMLApplyStylesheet.md) first.  
XML needs to have a root element with record elements inside and values inside.  
  
If a field is decimal type, we convert value to numeric. Please make sure your number values use dot or comma to match FileMaker's expectation.  
  
Returns number of records inserted or error message.  
  
In contrast to [XML.Import](XMLImport.md), XML.InsertRecords doesn't create table or fields. And XML.InsertRecords doesn't go into deeper levels.  
### Examples

Insert record:

 Set Variable \[$r ; Value: MBS ( "XML.InsertRecords"; "  
&lt;Records&gt;  
 &lt;Record&gt;  
 &lt;Firstname&gt;Joe&lt;/Firstname&gt;  
 &lt;LastName&gt;Miller&lt;/LastName&gt;  
 &lt;Age&gt;63&lt;/Age&gt;  
 &lt;/Record&gt;  
&lt;/Records&gt;";   
0; Get(FileName); "Kontakte" ) \]  
### See also

- [FM.InsertRecord](FMInsertRecord.md)
- [FM.InsertRecordCSV](FMInsertRecordCSV.md)
- [FM.InsertRecordTSV](FMInsertRecordTSV.md)
- [FM.SQL.InsertRecords](FMSQLInsertRecords.md)
- [JSON.InsertRecord](JSONInsertRecord.md)
- [JSON.InsertRecords](JSONInsertRecords.md)
- [SQL.InsertRecords](SQLInsertRecords.md)
- [XML.ApplyStylesheet](XMLApplyStylesheet.md)
- [XML.Import](XMLImport.md)
- [XML.Parse](XMLParse.md)

### Release notes

- **Version 13.4**
    - Added [XML.InsertRecords](https://www.mbsplugins.eu/XMLInsertRecords.shtml) function.

### Blog Entries

- [News in MBS FileMaker Plugin 13.4](https://www.mbsplugins.de/archive/2023-09-20/News_in_MBS_FileMaker_Plugin_1/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 13.4 für Claris FileMaker](https://www.mbsplugins.de/archive/2023-09-12/Neues_MBS_Plugin_134_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 13.4 for Claris FileMaker - More than 7100 Functions In One Plugin](https://www.mbsplugins.de/archive/2023-09-12/MBS_Plugin_134_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.4pr1](https://www.mbsplugins.de/archive/2023-08-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

Created 25th July 2023 , last changed 21st September 2023

  
[XML.Import.Work](XMLImportWork.md) - [XML.ItemRefs](XMLItemRefs.md)

[HTML Version](XMLInsertRecords.shtml)