Importing XML data
FileMaker Pro can import XML data into an existing FileMaker Pro file, or convert XML into a new FileMaker Pro file.
The XML can be a file, or the result of an HTTP request sent to a web server. For example, you could set up an Orders database to send tracking numbers to a package delivery company in the form of an HTTP request, and their web server could return the latest package tracking information in XML format, ready to be imported into the Orders database.
The XML that you import must conform to the FileMaker FMPXMLRESULT document type definition (DTD). If your XML is in a different format, you can apply an Extensible Stylesheet Language (XSLT) style sheet during import to transform your XML into the FMPXMLRESULT grammar. See XML format.
To import XML:
-
What you do first depends on whether you are importing XML into an existing FileMaker Pro file, or converting XML into a new FileMaker Pro file.
-
If you're updating matching records or replacing existing records, make a backup copy of the target file.
Important Updating matching records or replacing existing records overwrites data in the target file and cannot be undone. To safeguard your data, choose File menu > Save a Copy As to make a backup copy of the target FileMaker Pro file. You can do this only for a local file (located on your computer). Make sure you understand how updating or replacing records works. See Importing data into FileMaker Pro.
-
In FileMaker Pro, open the target file.
-
If the target file contains multiple tables, use the Layout pop-up menu to display a layout that shows records from the table you want to import data into.
-
If you're updating matching records or replacing existing records, do the following before you import. (If you're adding new records, skip to the next step.)
-
If you're updating matching records, make sure the found set contains only the records you want to update. Records outside the found set will not be updated, even if match field data matches.
-
If you're replacing existing records in the file, make sure the found set contains only the records you want to change. If necessary, sort the records so that data from the correct record in the source file replaces data in each record in the target file.
-
-
Choose File menu > Import Records > XML Data Source.
The Specify XML and XSL Options dialog box appears.
-
Skip ahead to step 10.
You should only follow steps 8 through 9 if you are converting XML into a new FileMaker Pro file.
-
In the Open File dialog box, for Files of type (Windows) or Show (macOS), choose XML Data Source.
The Specify XML and XSL Options dialog box appears.
-
For Specify XML Data Source, choose the source of the XML data to import.
The XML source can be a file or the result of an HTTP request.
-
To apply an XSLT style sheet to the XML before importing, select Use XSL style sheet and specify the source of the XSLT style sheet.
When the XML you're importing does not conform to the FMPXMLRESULT DTD, you must apply an XSLT style sheet that transforms the XML into the proper grammar. The XSLT source may be a file or the result of an HTTP request.
-
Click Continue.
Using a libxml2-based XML parser and a libxslt-based XSLT processor, FileMaker Pro applies an XSLT style sheet (if you specified one) to transform the XML data. If an error message appears, correct the error and try importing again.
-
Choose the import action to perform and map fields in the target file to the data you want to import from the source file. (See Setting the import action and mapping fields during import.) Choose options in the dialog box, then click Import.
If you are converting the XML into a new FileMaker Pro file, type a name for the new file, choose a location, then click Save.
To import XML |
Do this |
Into an existing FileMaker Pro file |
Continue with step 2. |
By converting the XML into a new FileMaker Pro file |
Skip ahead to step 8. |
Notes
-
For details about the requirements for well-formed XML, see the XML specification, which is available at www.w3.org/XML/.
-
FileMaker Pro uses the libxml2 XML parser, which supports XML data in the following character encodings:
-
ASCII
-
UTF-8
-
UTF-16 (Big/Small Endian)
-
UCS4 (Big/Small Endian)
-
ISO-8859-1 (Latin1)
-
-
In the Import Records script step when you specify XML Data as the data source, you can specify paths for the XML data and XSL style sheet in two ways:
-
For File, the path must be in FileMaker format (see Creating file paths).
-
For Calculation, the path must be the full path in the operating system's format. For example:
Windows:
driveletter:\directoryName\fileName
macOS:
/directoryName/fileName
If you are providing a cross-platform custom app, you can use the Get(SystemPlatform) function to identify the current platform and use the correct format for each platform.
-