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
*/
// ===================================
/* __LITBR__xmlGet ( _xml ; _tag )__LITBR____LITBR__by Fabrice Nordmann__LITBR__http://www.1-more-thing.com__LITBR____LITBR__v4, Feb 2008__LITBR____LITBR__generic xml tag extractor__LITBR__---__LITBR__v4 Feb 2008. Doesn't handle LayoutProperties anymore (LayoutProperties must now be passed in _xml parameter)__LITBR__v3 Dec 2007. Renamed xmlGet (was PropertyValue)__LITBR__v2.1 Aug 2007. Forces evaluation of ¶ by substitution de-substitution__LITBR__v2 May 2007__LITBR__v1 Renamed PropertyValue (was called ObjValue), and was working in a completely different way__LITBR__---__LITBR____LITBR__READ ME (IMPORTANT)__LITBR___xml will be parsed. This means a substract of 'XML' like code can be passed to this function.__LITBR____LITBR__to evaluate an expression in a xml tag rather than a plain text, when xmlGet is evaluated, it must begin with "=".__LITBR__e.g :__LITBR__ "3+4" --> "3+4"__LITBR__ "=3+4" --> "7"__LITBR____LITBR__-------------------------------------------------__LITBR__*/__LITBR__Let ([__LITBR__ _tagLength = Length ( _tag )__LITBR__ ; _tagStart = Position ( _xml ; "<" & _tag & ">" ; 1 ; 1 ) + _tagLength + 2__LITBR__ ; _tagEnd = Position ( _xml ; "</" & _tag & ">" ; _tagStart ; 1 )__LITBR__ ; _tag = Substitute ( Middle ( _xml ; _tagStart ; _tagEnd - _tagStart ) ; ¶ ; "ïMπRößablÊsTrìNg" )__LITBR__]__LITBR__;__LITBR__Substitute ( __LITBR__Case ( Left ( _tag ; 1 ) = "=" ;__LITBR__ Evaluate ( Replace ( _tag ; 1 ; 1 ; "" ))__LITBR__; Evaluate ( Quote ( _tag ))__LITBR__)__LITBR__; "ïMπRößablÊsTrìNg" ; ¶ )__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/110__LITBR____LITBR__ Prototype: xmlGet( _xml; _tag )__LITBR__ Function Author: Fabrice (http://www.fmfunctions.com/mid/37)__LITBR__ Last updated: 22 April 2010__LITBR__ Version: 1.2__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.