Brian Dunning's FileMaker Custom Functions

GetNthCdataContents ( xmlToSearch ; n )

Gets the contents of the nth CDATA instance within an XML blob.

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

Cristos Lianides-Chin   Cristos Lianides-Chin - Show more from this author
Codence
https://www.codence.com

Share on Facebook Share on Twitter

  Sample input:
GetNthCdataContents ( "T001832015-07-29 11:50:31]]> T001842015-07-29 11:50:31]]>" ; 2 )
  Sample output:
T001842015-07-29 11:50:31

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

GetNthCdataContents ( xmlToSearch ; n )

PURPOSE:
Gets the contents of the nth CDATA instance within an XML blob.

RETURNS:
Text string, of the data contained between the opening and closing CDATA tags.

EXAMPLE:
CALL:
GetNthCdataContents ( "T001832015-07-29 11:50:31]]> T001842015-07-29 11:50:31]]>" ; 2 )
RESPONSE:
"T001842015-07-29 11:50:31"

 

Comments

Bruce   Bruce, Redmond WA
Oct 1, 2015
Sorta works.
However, if you ask for N outside the range of actual values, it does not work correctly. For instance, in your example, which has two occurrences of CDATA, ask for N with a value of 5. Oops.
 
Cristos Lianides-Chin   Cristos Lianides-Chin, Codence
Oct 1, 2015
Thanks for pointing out the issue, Bruce. I've updated the code to return "?" if *n* is out-of-bounds.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. 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 20 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: