xmlSetH ( )

Function stats

Average user rating
224
246
9999
Support
FileMaker 7.0 +
Date posted
12 December 2009
Version
1
Recursive function
Yes

Author Info
 konrad

10 functions

Average Rating None

author_avatar



 

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: 12 December 2009
    Version: 1

*/
// ===================================

 

 

 

 


Login or register to comment

Create a new account with fmcustomfunctions.com or login to post a comment.