The Support Group Blog

One Interesting Way to Use FileMaker XML Files

Written by The Support Group | Mar 24, 2021 3:15:00 PM

Claris introduced a new feature in version 18 of the FileMaker Platform called Save a Copy as XML. You can find this command within the Tools menu if you have the "use advanced tools" option enabled in the FileMaker desktop application's Preferences section. With this menu command, Claris gives us a window into each of our custom apps' inner workings, as well as a way to more easily document even the most complex ones.

Extensible Markup Language (XML) is a web development tool used to store and transport data. Like HTML, which is a markup language for data presentation, XML requires opening and closing tags. XML is useful for FileMaker development because it facilitates the exchange of data between two systems. However, we can also use it to parse or read our data. In this article, we'll explore how we can protect the integrity of our FileMaker applications as we scale and evolve them.

As we use FileMaker to solve our endless backlog of business and organizational challenges, we inevitably add more and more complexity to our solutions. As our applications become more complex, it takes us more time to sift through it when we want to change one part of the application without inadvertently changing other parts. For example, let's say we need to change some aspect of a script to make it work differently in a new situation. We could go straight in and make the modification we want and test it appropriately to make sure it works. But if we have a complex system, as many of us do, it would be hard to determine if any other workflows call the script in question. It's important to consider the impact of our changes because if different scripted workflows expect it to work the original way, it could cause problems. How do we know if other scripts call this newly edited one? This is where the Save a Copy as XML function comes in, but we'll have to review the structure of the resulting file to unlock its secrets.

If you open up the resulting XML file in the text editor of your choice, you'll see what appears to be a mishmash of structured text.

Parse XML

When you first open the XML file FileMaker produces, it might appear to be just a jumble of text. It helps if you open it with a text editor that color formats XML, like Microsoft's cross-platform and free Visual Code Studio. To be honest, even someone who has experience reading XML documents might find the text to be cryptic initially. 

XML, by its nature, is a fairly structured affair, so take heart. First each element in an XML document starts with an opening tag, <ObjectName>, and an ending tag, </ObjectName>. Everything contained within these two tags is somehow related to this object, and we can see a count of the objects that are contained with it. Within these tags are more tag pairs that call out different parent tag characteristics, such as more instances of the object or aspects like color or location. Also, within these child tags, we see name-value pairs that describe the tag's low-level attributes, like the RGB values of a color. 

Let's look at the above example as we walk through what to look for within the XML file. The first part, <UUID>, is the universally unique identifier (UUID) for the object. FileMaker gives every object a UUID because that makes it portable (easily copied) between files without the danger of conflicting with existing objects. We also notice some information about how many times the object has been modified, by whom, and when inside the UUID tag. The rest of the tags and values are typically specific to this type of object. The example object, which is a Table Occurrence, includes attributes like its color, location on the graph, and the base table attached to it.

Here is a list of some of the important objects we will find in the XML:


    • Tables: <BaseTableCatalog>
    • Fields by table: <FieldsForTables>
    • Table Occurrences: <TableOccurrenceCatalog>
    • Relationships: <RelationshipCatalog>
    • Custom Functions: <CustomFunctionsCatalog>
    • Value Lists: <ValueListCatalog>
    • Calculations used by Custom Functions: <CalcsForCustomFunctions>
    • Scripts: <ScriptCatalog>
    • Script Steps: <StepsForScripts>
    • Themes: <ThemeCatalog>
    • Layouts and their Objects: <LayoutCatalog>

This list is just a sampling of what our XML files could include because everything that makes up our custom FileMaker app, from File Options to Privilege Sets, is written into them. Once we get familiar with these files, we can search for all sorts of things, like whether any container fields are set to "External Storage," if the Set Field By Name script steps are used, or even how many table occurrences are contained within the file. So let's start exploring these files and unlock a treasure of secrets about our apps.

Find more FileMaker tips and tricks, like how to manage FileMaker error codes and how to move data from repeating fields, to help you simplify your app development process. Join our mailing list to keep up with the latest low-code and no-code app development techniques.

This article is also published on FileMakerProGurus.com