Skip to main content

TrText_XML (function reference)

By October 1, 2024October 10th, 2024Online Help, Troi Text Plug-in
Troi Text Plug-in for FileMaker Pro

TrText_XML

Returns the requested parts from text formatted as XML.

SyntaxFunction badge

TrText_XML ( switches ; nodeSpec ; XMLData )

Parameters

switches determine which data is returned
nodeSpec the node you want data from
XMLData the text which contains XML formatted data

Switches

Switches can be one of this:

-GetNode return the node data
-GetAttributes return the node attributes

Specifying Nodes:
Child nodes are specified from the root of the node downwards, and are separated by a slash: ‘/’. For example:

abc/def/ghi

If the XML contains multiple occurrences of a node you can retrieve a specific node by adding a number like this:

abc/def[2]/ghi[3]

This will get the 3rd ‘ghi’ node from the 2nd ‘def’ node of abc.

You can add spaces to the node specification to improve readability.

Returned Result

Data type returned

Text

Result

The XML data requested, either the node or the attributes of the node.

Originated in

Troi Text Plug-in 1.2

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

The XML parsing function of Troi Text Plug-in has some known limitations:

No XML validation
Parsing will only be correct with a well-formed XML document (or a part thereof). If this is not the case the plug-in will try to parse it anyway, but the result may be unpredictable. The plug-in does not validate the XML.

Limited attribute retrieval
The plug-in can only return all attributes of a node at once. From this you have to get the individual attributes out yourself. An easy function to get a specified attribute out is on our own wish list. For the moment you can use the text functions in FileMaker to extract these from the “Attribute data” field.

Processing instructions and comments are not returned
The plug-in can’t return processing instructions like “<?xml version=”1.0″ ?>” and comments. We think there is little need for this functionality. You can use the text functions in FileMaker Pro to extract these from the “XML data” field.

Example

TrText_XML ( "-GetNode" ; "transaction/product/name" ; XML data )

Example 2

Say the field XML data contains this text:
<?xml version=”1.0″?>
<xsd>
<vendor id=”12″ >Troi Automatisering</vendor>
<product>Time machine 1.0</product>
<product>Hit Maker</product>
</xsd>

Then:

TrText_XML ( "-GetNode" ; "xsd/vendor" ; XML data )

returns ‘Troi Automatisering’.

TrText_XML ( "-GetAttributes" ; "xsd/vendor" ; XML data )

returns ‘id=”12″ ‘.

TrText_XML ( "-GetNode" ; "xsd/vendor/product[2]" ; XML data )

returns ‘Hit Maker’.

Used in example file

ParseXML.fmp12

Related functionFunction badge

TrText_GetClipboardAsText

Related topics

Troi Text Plug-in online help (overview)


Online Help Page for Troi Text Plug-in for 17 to 2024 –> TrText_XML (textp15) 2024-1010 14:58:47