xmlReplaceNodeValue ( )

Function stats

Average user rating
5.0000
148
408
9999
Support
FileMaker 7.0 +
Date posted
29 December 2016
Version
1
Recursive function
No

Author Info
 Steve Allen

15 functions

Average Rating 5.0

author_avatar



 

Function overview

Prototype

xmlReplaceNodeValue  ( xml;   tag;   newValue )


Parameters

xml  The original XML chunk


tag  The XML node name whose value will be replaced.


newValue  The value with which to replace the existing value for the specified node name.


Description

Tags:  XML  

Allows you to set a specified node in an XML chunk with a different value, without affecting the rest of the XML.

Examples

Sample input

xmlReplaceNodeValue ( "<name><first>Steven</first><last>Allen</last></name>" ; "first" ; "Randall" )


Sample output

<name><first>Randall</first><last>Allen</last></name>

 

Function code

Let ([
    tagOpen = "<" & tag & ">"
;    tagClose    = Replace ( tagOpen ; 2 ; 0 ; "/" )
;    numStart    = Position ( xml ; tagOpen ; 1 ; 1 ) + Length ( tagOpen )
;    numEnd    = Position ( xml ; tagClose ; tagClose ; 1 )
;    output    = Replace ( xml ; numStart ; numEnd - numStart ; newValue )
];
output
)

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

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

    Prototype: xmlReplaceNodeValue( xml; tag; newValue )
    Function Author: Steve Allen (http://www.fmfunctions.com/mid/148)
    Last updated: 29 December 2016
    Version: 1

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

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Layout  (15)
Interface  (15)
Text  (14)
Variables  (12)
Filter  (11)
Layout Objects  (11)
Design  (10)
Array  (8)