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:
9.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
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. Can be empty. | Get(FileName) | |
TableNamePrefix | The prefix to put in front of all tables. | "Import" | Optional |
Flags | Sum of flags. Pass 1 to ignore errors in xml and continue parsing. Pass 2 to ignore outer XML wrapper nodes. Pass 4 to import flat, so no subtables for included nodes. Pass 8 to convert CDATA to text nodes. CData should contain ASCII or UTF-8 text! Pass 16 to trim values. |
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")]
Created 8th September 2015, last changed 3th April 2021
XML.HasAttribute - XML.Import.Cancel
Feedback: Report problem or ask question.