Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Imports XML and creates tables, fields and records.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
XML | 5.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
XML | The XML data to import. | ||
InsertFileName | The file name of where the insert table is inside. | Get(FileName) | Optional |
TableNamePrefix | The prefix to put in front of all tables. | "Import" | Optional |
Flags | Sum of flags. Add 1 to ignore errors in xml and continue parsing. Add 2 to ignore outer XML wrapper nodes. Add 4 to import flat, so no subtables for included nodes. Add 8 to convert CDATA to text nodes. CData should contain ASCII or UTF-8 text! Add 16 to trim values. Add 128 to skip table creation (since v12.3). Add 256 to skip field creation (since v12.3). |
0 | Optional |
Returns number or error.
Imports test.xml into FileMaker:
Set Variable [$text; Value:MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.xml"; "UTF-8")]
Set Variable [$r; Value:MBS("XML.Import"; $text; ""; "")]
Set Variable [$text; Value:""]
If [MBS("IsError") = 0]
Set Variable [$total; Value:MBS("XML.Import.Total")]
Loop
Set Variable [$todo; Value:MBS("XML.Import.Todo")]
Pause/Resume Script [Duration (seconds): 1]
Set Variable [$s; Value:MBS("XML.Import.Status")]
Exit Loop If [$s ≠ "Working"]
End Loop
Show Custom Dialog ["XML Import"; $r & " " & $s]
End If
Import script with progress bar for importing XML with Windows ANSI encoding:
Go to Layout [“XML Import” (Import2Row)]
Delete All Records [No dialog]
Set Variable [$r; Value:MBS("ProgressDialog.SetBottomText"; "")]
Set Variable [$r; Value:MBS("ProgressDialog.SetTopText"; "Importiere XML")]
Set Variable [$r; Value:MBS("ProgressDialog.SetTitle"; "Import...")]
Set Variable [$r; Value:MBS("ProgressDialog.SetButtonCaption"; "Abbrechen")]
Set Variable [$r; Value:MBS("ProgressDialog.SetProgress"; -1)]
Set Variable [$r; Value:MBS("ProgressDialog.Show")]
Pause/Resume Script [Duration (seconds): ,1]
Set Variable [$text; Value:MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.xml"; "Windows")]
Set Variable [$r; Value:MBS("XML.Import"; $text; ""; "Import2")]
Set Variable [$text; Value:""]
If [MBS("IsError") = 0]
Set Variable [$total; Value:MBS("XML.Import.Total")]
Loop
Set Variable [$todo; Value:MBS("XML.Import.Todo")]
Set Variable [$r; Value:MBS("ProgressDialog.SetProgress"; ($total - $todo) * 100 / $total)]
Set Variable [$r; Value:MBS("ProgressDialog.SetBottomText"; "Schritt " & ($total - $todo) & " von " & $total)]
Pause/Resume Script [Duration (seconds): 1]
Set Variable [$s; Value:MBS("XML.Import.Status")]
Exit Loop If [$s ≠ "Working"]
If [MBS("ProgressDialog.GetCancel") = 1]
Set Variable [$r; Value:MBS("ProgressDialog.Hide")]
Set Variable [$r; Value:MBS("XML.Import.Cancel")]
Exit Script []
End If
End Loop
Set Variable [$r; Value:MBS("ProgressDialog.Hide")]
Show Custom Dialog ["XML Import"; $r & " " & $s]
End If
Set Variable [$r; Value:MBS("ProgressDialog.Hide")]
Read Database Design Report:
#read XML from file in UTF-16
Set Variable [$text; Value:MBS("Text.ReadTextFile"; "/Users/cs/Desktop/test.xml"; "UTF-16")]
# now remove the UTF-16 encoding marker
Set Variable [$text; Value:Substitute($text; "<?xml version=\"1.0\" encoding=\"UTF-16\"?>"; "")]
#read XML from file
Set Variable [$r; Value:MBS("XML.Import"; $text; ""; "Import")]
Explicit import with passing database filename:
MBS("XML.Import"; $text; Get(FileName); "Import")
This function checks for a license.
Created 8th September 2015, last changed 22nd March 2023