xmlSet ( )

Function stats

Average user rating
5.0000
37
109
9999
Support
FileMaker 7.0 +
Date posted
05 December 2008
Last updated
07 February 2010
Version
Recursive function
No

Author Info
 Fabrice

79 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

xmlSet  ( _tag;   _data )


Parameters

_tag  


_data  


Description

Tags:  XML  

sets up and xml string such as <tag>data</tag>
can be nested :
xmlSet ( "TABLE" ; xmlSet ( "TR" ; xmlSet ( "TD" ; "Hello" ) & xmlSet ( "TD" ; "World" ))) = <TABLE><TR><TD>Hello</TD><TD>World</TD></TR></TABLE>

Examples

Sample input

xmlSet ( "TABLE" ; xmlSet ( "TR" ; xmlSet ( "TD" ; "Hello" ) & xmlSet ( "TD" ; "World" )))


Sample output

<TABLE><TR><TD>Hello</TD><TD>World</TD></TR></TABLE>

 

Function code

/*
xmlSet ( _tag ; _data )

by Fabrice Nordmann
http://www.1-more-thing.com

v.1, Dec 2007


sets up and xml string such as <tag>data</tag>
can be nested :
xmlSet ( "TABLE" ; xmlSet ( "TR" ; xmlSet ( "TD" ; "Hello" ) & xmlSet ( "TD" ; "World" ))) = <TABLE><TR><TD>Hello</TD><TD>World</TD></TR></TABLE>
*/


"<" & _tag & ">" & _data & "</" & _tag & ">"

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

    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/109

    Prototype: xmlSet( _tag; _data )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 07 February 2010
    Version: 1.2

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

 

Comments

NicolasJ
12 May 2009



Very nice and useful function to pass complex parameters to scripts.
How can we do to replace the content of one tag in a pseudo-xml string?
     Feature request
Fabrice
22 May 2009



Hi Nicolas,
what you can do is : (requires xmlSet and xmlGet )
Let ([
_xml = $yourXMLhere
; _tagToReplace = $theTagToReplaceHere
; _newValue = $theNewValueHere
; _string = xmlGet ( _xml ; _tagToReplace )
];
Replace ( _xml ; position ( _xml ; _string ; 0 ; 1 ) ; length ( _string ) ; xmlSet ( _tagToReplace ; _newValue ))
)
(Edited by Fabrice on 22/05/09 )
  General comment