Function overview
Prototype
xmlSetH (
name; value; xml )
Parameters
name
value
xml
Description
Tags:
xml
store multible named values in one field or variable!
usefull to pass over multible values as a scriptparameter
sets value of a tag within a xml by hierachical name, where the name includes the position of the value in the xml structure like "contact.ID" for the tag "ID" inside the tag "contact"
if the tag is already there, the value will be updated
if the tag is new, it will be appended
if the value is "", the tag will be removed
Examples
Sample input
xmlSetH ( "contact.ID" ; "8888" ;
"<contact>
<ID>2354</ID>
<Lastname>Frank</Lastname>
</contact>
<letter>
<ID>234</ID>
</letter>"
Sample output
<contact>
<ID>8888</ID>
<Lastname>Frank</Lastname>
</contact>
<letter>
<ID>234</ID>
</letter>
Function code
//set the value of the name tag
//name has format name1.name2.name3 ...
Let([
dot1 = Position ( name ; "."; 1; 1);
name1=If( dot1 > 0 ; Left ( name ; dot1 - 1) ; name ) ;
nameR=If( dot1 > 0 ; Right ( name ; Length ( name ) - dot1 ) ) ;
xml0 = xmlSetTop ( name1 ;
If ( dot1 > 0 ;
xmlSetH ( nameR; value ; xmlGetTop ( name1 ; xml )) ; value ) ; //recursion!
xml ) ] ;
TrimSpaceCR ( xml0 )
)
// ===================================
/*
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/246
Prototype: xmlSetH( name; value; xml )
Function Author: konrad (http://www.fmfunctions.com/mid/224)
Last updated: 13 December 2009
Version: 1
*/
// ===================================
//set the value of the name tag__LITBR__//name has format name1.name2.name3 ...__LITBR____LITBR__Let([__LITBR____LITBR__dot1 = Position ( name ; "."; 1; 1);__LITBR__name1=If( dot1 > 0 ; Left ( name ; dot1 - 1) ; name ) ;__LITBR__nameR=If( dot1 > 0 ; Right ( name ; Length ( name ) - dot1 ) ) ;__LITBR__xml0 = xmlSetTop ( name1 ; __LITBR__ If ( dot1 > 0 ; __LITBR__ xmlSetH ( nameR; value ; xmlGetTop ( name1 ; xml )) ; value ) ; //recursion!__LITBR__ xml ) ] ; __LITBR__TrimSpaceCR ( xml0 ) __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/246__LITBR____LITBR__ Prototype: xmlSetH( name; value; xml )__LITBR__ Function Author: konrad (http://www.fmfunctions.com/mid/224)__LITBR__ Last updated: 13 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.