Function overview
Prototype
xmlGetTop (
name; xml )
Parameters
name
xml
Description
store multible named values in one field or variable!
usefull to pass over multible values as a scriptparameter
gets value of a tag with given name, only when tag found in the top level of the given hierarchical xml structure
scans through the top level tags by recursion
return value can also be child xml from the named tag
Examples
Sample input
xmlGetTop ( "contact" ;
"<contact>
<ID>2354</ID>
<Lastname>Frank</Lastname>
</contact>
<letter>
<ID>234</ID>
</letter>"
Sample output
<ID>2354</ID>
<Lastname>Frank</Lastname>
Function code
Let([
name0 = xmlFirstTagName ( xml );
xmlR = xmlWithoutFirstTag ( xml );
value = If( name0=name;
xmlFirstTagValue ( xml );
If ( PatternCount ( xmlR; "<"&name&">" )>0 ;
xmlGetTop ( name ; xmlR) ; //recursion!
""
)
) ];
TrimSpaceCR ( value )
)
// ===================================
/*
This function is published on FileMaker Custom Functions
to check for updates and provide feedback and bug reports
please visit http://www.fmfunctions.com/fid/244
Prototype: xmlGetTop( name; xml )
Function Author: konrad (http://www.fmfunctions.com/mid/224)
Last updated: 12 December 2009
Version: 1
*/
// ===================================
Let([__LITBR____LITBR__name0 = xmlFirstTagName ( xml );__LITBR__xmlR = xmlWithoutFirstTag ( xml );__LITBR__value = If( name0=name; __LITBR__ xmlFirstTagValue ( xml );__LITBR__ If ( PatternCount ( xmlR; "<"&name&">" )>0 ;__LITBR__ xmlGetTop ( name ; xmlR) ; //recursion!__LITBR__ ""__LITBR__ )__LITBR__ ) ];__LITBR____LITBR__TrimSpaceCR ( value ) __LITBR__ __LITBR__ )__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/244__LITBR____LITBR__ Prototype: xmlGetTop( name; xml )__LITBR__ Function Author: konrad (http://www.fmfunctions.com/mid/224)__LITBR__ Last updated: 12 December 2009__LITBR__ Version: 1__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.