Brian Dunning's FileMaker Custom Functions

GetXmlContent ( theXml ; theNodeName ; theInstanceNumber )

Extract data from XML snippet which may contain attributes and/or erroneous partial matches

  Average rating: 4.6 (25 votes) Log in to vote

JT   JT - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
GetXmlContent ( theXml ; "test" ; 2 )

Where theXml =

  Sample output:

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function was inspired by Andy Knasinski's ExtractData ( ) and expanded to account for erroneous partial-match error returns and multiple matching instances which may or may not contain attributes.



comment   comment, VR
Feb 17, 2015
It is a common misconception that XML can be easily and relaible paresed using text function. Consider the folowing example:

<test xmlns="urn:X-ample:1">two</test>
<test>the real two</test>

What is the value of the second occurrence of element named "test"? The above CF tells us it is "two", but the correct answer is "the real two" - compare:
john renfrew   john renfrew, attitude
Feb 25, 2015
~positionNodeTest = Position ( ~xmlTransformed ; RARETEXT ; 1 ; theInstanceNumber );

should be:
~positionNodeTest = Position ( ~xmlTransformed ; RARETEXT ; 1 ; ~instanceNumber );
Feb 25, 2015
Fixed, thanks John. I noticed that earlier but hadn't a chance to fix it yet.

comment, good point about the namespacing. But for my purposes at least, "two" would be the correct result. Caveat Functioner, I guess.
Bruce Robertson   Bruce Robertson
Apr 13, 2015
Does not compile as written. There is no Null function.

Case (
IsEmpty ( theXml )
or IsEmpty ( theNodeName ) ;
Null; // RETURN
Apr 13, 2015
Fixed. Thanks, Bruce!

Log in to post comments.


Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.