FM.SQL.XMLRecord
----------------

Returns a row as XML object.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [FM](component_FM.md) [FMSQL](component_FMSQL.md) [XML](component_XML.md) | [10.3](newinversion103.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "FM.SQL.XMLRecord"; SQLref; RecordNodeName; Row; FieldNames { ; Flags } ) 

**MBS**( **"FM.SQL.XMLRecord";** /\* Returns a row as XML object. \*/  
**$SQLref**; /\* The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. \*/   
**$RecordNodeName**; /\* The name for the parent XML nodes for ome record.  
Defaults to "record".e.g. "Company" \*/   
**$Row**; /\* The row you like to get.  
Zero based.e.g. 0 \*/   
**$FieldNames**; /\* A list of field names for the XML.e.g. "Model¶Names" \*/   
**$Flags**) /\* Optional; The flags for the XML creation.  
Pass 1 to get all values as text.  
Pass 2 to get all dates, times and timestamps in SQL format.e.g. 1+2 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| SQLref | The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. | $SQLRef |  |
| RecordNodeName | The name for the parent XML nodes for ome record.   Defaults to "record". | "Company" |  |
| Row | The row you like to get.   Zero based. | 0 |  |
| FieldNames | A list of field names for the XML. | "Model¶Names" |  |
| Flags | The flags for the XML creation.   Pass 1 to get all values as text.   Pass 2 to get all dates, times and timestamps in SQL format. | 1+2 | Optional |

### Result

Returns OK or error.

### Description

Returns a row as XML object.  
You provide list of field names, which should be in same order as fields in SQL result.  
Optionally we can return SQL dates, times and timestamps as SQL format.  
Containers are returned as Base64 encoded data.  
### Examples

Query records as XML:

 # run query to get some data   
Set Variable \[ $sql ; Value: MBS ( "[FM.SQL.Execute](FMSQLExecute.md)"; ""; "SELECT \\"First\\", \\"Last\\", Company, \\"Photo Container\\" FROM Contacts") \]   
\# query data   
Set Variable \[ $xml ; Value: MBS ( "FM.SQL.XMLRecord"; $sql ; "person"; 0; "First¶Last¶Company¶Photo"; 2) \]   
\# store result   
Set Field \[ Contacts::Output ; $xml \]   
\# free memory   
Set Variable \[ $xml ; Value: MBS ( "[FM.SQL.Release](FMSQLRelease.md)"; $sql ) \]  
### See also

- [FM.SQL.Execute](FMSQLExecute.md)
- [FM.SQL.JSONRecord](FMSQLJSONRecord.md)
- [FM.SQL.JSONRecords](FMSQLJSONRecords.md)
- [FM.SQL.Release](FMSQLRelease.md)
- [FM.SQL.XMLRecords](FMSQLXMLRecords.md)
- [SQL.Execute](SQLExecute.md)

### Release notes

- **Version 14.2**
    - Added firstRow and lastRow parameter to [FM.SQL.JSONRecords](https://www.mbsplugins.eu/FMSQLJSONRecords.shtml) and [FM.SQL.XMLRecords](https://www.mbsplugins.eu/FMSQLXMLRecords.shtml) functions.

### Blog Entries

- [MBS FileMaker Advent calendar - Door 21 - XML](https://www.mbsplugins.de/archive/2025-12-21/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [What is new in the MBS FileMaker Plugin Version 10.3](https://www.mbsplugins.de/archive/2020-07-31/What_is_new_in_the_MBS_FileMak/monkeybreadsoftware_blog_filemaker)
- [FileMaker records to XML or JSON](https://www.mbsplugins.de/archive/2020-06-30/FileMaker_records_to_XML_or_JS/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 29th June 2020 , last changed 6th March 2026

  
[FM.SQL.ToMatrix](FMSQLToMatrix.md) - [FM.SQL.XMLRecords](FMSQLXMLRecords.md)

[HTML Version](FMSQLXMLRecord.shtml)