Brian Dunning's FileMaker Custom Functions

GetXMLNode ( XML ; XPath )

Navigate XML tree and return results using XPath type functionality (Nonrecursive)

  Average rating: 4.1 (43 votes) Log in to vote

Michael Wallace   Michael Wallace
Richard Carlton Consulting
http://www.rcconsulting.com

Share on Facebook Share on Twitter

  Sample input:
XMLfield is set to:
BillSue
GetXMLNode ( XMLfield ; "/class[1]/student[1]" ) & "¶" &
GetXMLNode ( XMLfield ; "/class[1]/student[2]" )
  Sample output:
Bill
Sue

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

Navigate XML tree and return results using XPath type functionality.

Parameter Description
XML - vanilla xml imput without attributes
XPath - basic XPath like syntax consiting of a series of xml nodes formatted as follows:
/nodeName[instanceNumber]


Requires ExtractData ( XML ; Attribute ; Instance ) by Andy Knasinski of NRG Software which can be found at http://www.briandunning.com/cf/1

Thanks to Andy for the great base function!

This function is not recursive. It simply creates multiple nested instances of ExtractData in a calculation string and then evaluates it to get the data.

*************
EXAMPLE USE
*************
XMLfield is set to:


Kelly



Bill
15


Sue
16




GetXMLNode ( XMLfield ; "/class[1]/teacher[1]/name[1]" ) & "¶" &
GetXMLNode ( XMLfield ; "/class[1]/students[1]/student[2]/age[1]" ) & "¶" &
GetXMLNode ( XMLfield ; "/class[1]/students[1]/student[1]" )

Will produce the following:
Kelly
16
Bill15

 

Comments

Bruce Robertson   Bruce Robertson
Feb 16, 2009
Trailing section of example is incorrect, <class> should be </class>
 
Michael Wallace   Michael Wallace, Fairfield CA
Feb 26, 2009
Thanks Bruce, correction made.
 
Bruce Robertson   Bruce Robertson
Nov 1, 2013
No, it has not been corrected, in the Sample Input section here where you state "XMLfield is set to: … "
 
Simon Plint   Simon Plint, Australia
Oct 26, 2014
"Nonrecursive, this function simply creates multiple nested instances of GetXMLData in a calculation string and then evaluates it to get the data."

Don't you mean ExtractData instead of GetXMLData?
 
Mike Wallace   Mike Wallace, Dallas Texas
Apr 27, 2015
Fixed the typo in the description. Thanks Simon.
 

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.

Under construction. Email me your wish list for improvements.