xmlGet ( )

Function stats

Average user rating
5.0000
37
110
9999
Support
FileMaker 7.0 +
Date posted
05 December 2008
Last updated
22 April 2010
Version
Recursive function
No

Author Info
 Fabrice

54 functions

Average Rating 4.3

author_avatar



 

Function overview

Prototype

xmlGet  ( _xml;   _tag )


Parameters

_xml  


_tag  


Description

Tags:  XML  

extracts a value from an xml tag.
If the value begins with "=" (equal), then the result is evaluated.

_xml will be parsed. This means a substract of 'XML' like code can be passed to this function.

To evaluate an expression in a xml tag rather than a plain text, when xmlGet is evaluated, it must begin with "=".
e.g :
"3+4" --> "3+4"
"=3+4" --> "7"

Examples

Sample input

xmlGet ( "<firstname>John</firstname><surname>Smith</surname>" ; "surname" )


Sample output

Smith

 

Function code

/*
xmlGet ( _xml ; _tag )

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

v4, Feb 2008

generic xml tag extractor
---
v4 Feb 2008. Doesn't handle LayoutProperties anymore (LayoutProperties must now be passed in _xml parameter)
v3 Dec 2007. Renamed xmlGet (was PropertyValue)
v2.1 Aug 2007. Forces evaluation of ¶ by substitution de-substitution
v2 May 2007
v1 Renamed PropertyValue (was called ObjValue), and was working in a completely different way
---

READ ME (IMPORTANT)
_xml will be parsed. This means a substract of 'XML' like code can be passed to this function.

to evaluate an expression in a xml tag rather than a plain text, when xmlGet is evaluated, it must begin with "=".
e.g :
"3+4" --> "3+4"
"=3+4" --> "7"

-------------------------------------------------
*/
Let ([
_tagLength = Length ( _tag )
; _tagStart = Position ( _xml ; "<" & _tag & ">" ; 1 ; 1 ) + _tagLength + 2
; _tagEnd = Position ( _xml ; "</" & _tag & ">" ; _tagStart ; 1 )
; _tag = Substitute ( Middle ( _xml ; _tagStart ; _tagEnd - _tagStart ) ; ¶ ; "ïMπRößablÊsTrìNg" )
]
;
Substitute (
Case ( Left ( _tag ; 1 ) = "=" ;
Evaluate ( Replace ( _tag ; 1 ; 1 ; "" ))
; Evaluate ( Quote ( _tag ))
)
; "ïMπRößablÊsTrìNg" ; ¶ )
)

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

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

    Prototype: xmlGet( _xml; _tag )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 22 April 2010
    Version: 1.2

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

 

 

 

 


Login or register to comment

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