« Xojo Developer Confer… | Home | BKS Shorts 1.8.0 »

New XML Functions in MBS FileMaker Plugin

The last days I chatted with a FileMaker developer who had a need for some XML handling functions. So I added a few functions, first one to extract node names from an XML: XML.NodeNames. You pass in a XML and it can give you the list of node names in the first layer or if you want recursively all layers.

Next we got a function to get a subtree (XML.SubTree). So you may have a big XML with a smaller chunks and we can query nodes inside a bigger tree. This includes getting the nth entry like the nth record in a list of records.

The XML.ExtractText extracts the text inside an XML tree. So all text portions are returned as a list. You can first use the subtree function to get a part of a XML to only get a portion of the texts.

We got a few functions to handle attributes. XML.GetAttribute returns the value for the attribute.

Setting Variables

Now we got something special for FileMaker Scripts.

We parse an XML with the XML.SetVariables function, identify all nodes with text values and create variables for you automatically. The plugin sets those variables and returns a list of the names. Later you can pass the list to XML.ClearVariables to clear them for another run.

For example the script looks like this:

Set Variable [$XMLVariables; Value:MBS( "XML.SetVariables"; test::input; 1)]

Set Variable [$otherVariable; Value:1]

#See Variables in Data Viewer

Set Field [test::output; MBS( "XML.ClearVariables"; $XMLVariables)]

Set Variable [$someVariable; Value:1]


The test XML:
<?xml version="1.0" encoding="UTF-8"?>
<Job>
<Name>Test</Name>
<CreationDate>2016-11-23 12:34:56</CreationDate>
<Reference>8F223E5F-6A57-4ECD-9AB2-0FD0DA3414FF</Reference>
<Priority>5</Priority>
<Comment>Just a test.</Comment>
<Labels>
<Label>green</Label>
<Label>work</Label>
<Label>test</Label>
<Label>important</Label>
</Labels>
</Job>
And in the debugger all the variables may look like this for a test XML:



So you can have an input XML, split the values into variables using our plugin and process them in your script. I hope this is handy for you. What do you think?
Plugin will be available soon. If you like to test today, you can email me.
27 12 16 - 17:53