Function overview
Prototype
GetRealXMLFromWebViewer (
_html )
Parameters
_html The html/xml returned with GetLayoutObjectAttribute (
Description
Tags:
XML webviewer
The result returned by GetLayoutObjectAttribute ( "wv" ; "content" ) is different on Mac as on PC, certainly when dealing with XML.
The rendering engine on PC has the nice behavior it tries to make it readable from within the browser, so it wraps some nice HTML around it.
This is not really what you want when you want to get the XML from a webservice by using the "webviewer" technique. This custom function transforms the HTML generated by the webviewer back into a normal XML format.
Examples
Sample input
Let (
_contentWebViewer = GetLayoutObjectAttribute ( "wv" ; "content )
;
GetRealXMLFromWebViewer ( _contentWebViewer )
)
Sample output
for both platforms the same XML result
Function code
Case (
Abs ( Get ( SystemPlatform ) ) = 1 or Get ( SystemPlatform ) = 3 ; _html ; //because it just works on a OS and iOS :-)
//Welcome to windows
Let ( [
_htmlBody = BetweenNext ( _html ; "<BODY class=\"st\">" ; 1 ; 0 ; "</BODY>" ; 1 ; 0 );
_removedHTMLTags = Substitute ( _htmlBody ;
[ "<DIV class=\"e\">" ; "" ];
[ "<DIV class=\"b\">" ; "" ];
[ "<DIV class=\"m\">" ; "" ];
[ "<DIV class=\"c\" STYLE=\"margin-left:1em;text-indent:-2em\">" ; "" ];
[ "</DIV>" ; "" ];
[ "<DIV STYLE=\"margin-left:1em;text-indent:-2em\">" ; "" ];
[ "<DIV>" ; "" ];
[ "<SPAN class=\"pi\">" ; "" ];
[ "<SPAN class=\"m\">" ; "" ];
[ "<SPAN class=\"b\">" ; "" ];
[ "<SPAN class=\"t\">" ; "" ];
[ "<SPAN class=\"tx\">" ; "" ];
[ "</SPAN>" ; "" ];
[ "<A href=\"#\" onclick=\"return false\" onfocus=\"h()\" class=\"b\">" ; "" ];
[ "-</A>" ; "" ]
);
_convertToTags = Substitute ( _removedHTMLTags;
[ "<" ; "<" ];
[">" ; ">" ];
[ " " ; " " ]
);
_result = _convertToTags
];
_result
)
)
// ===================================
/*
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/322
Prototype: GetRealXMLFromWebViewer( _html )
Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)
Last updated: 17 February 2012
Version: 1.1
*/
// ===================================
Case ( __LITBR__Abs ( Get ( SystemPlatform ) ) = 1 or Get ( SystemPlatform ) = 3 ; _html ; //because it just works on a OS and iOS :-)__LITBR____LITBR____LITBR__//Welcome to windows__LITBR__Let ( [__LITBR____LITBR___htmlBody = BetweenNext ( _html ; "<BODY class=\"st\">" ; 1 ; 0 ; "</BODY>" ; 1 ; 0 );__LITBR___removedHTMLTags = Substitute ( _htmlBody ; __LITBR____LITBR__ [ "<DIV class=\"e\">" ; "" ];__LITBR__ [ "<DIV class=\"b\">" ; "" ];__LITBR__ [ "<DIV class=\"m\">" ; "" ];__LITBR__ [ "<DIV class=\"c\" STYLE=\"margin-left:1em;text-indent:-2em\">" ; "" ];__LITBR__ [ "</DIV>" ; "" ];__LITBR__ [ "<DIV STYLE=\"margin-left:1em;text-indent:-2em\">" ; "" ];__LITBR__ [ "<DIV>" ; "" ];__LITBR__ [ "<SPAN class=\"pi\">" ; "" ];__LITBR__ [ "<SPAN class=\"m\">" ; "" ];__LITBR__ [ "<SPAN class=\"b\">" ; "" ];__LITBR__ [ "<SPAN class=\"t\">" ; "" ];__LITBR__ [ "<SPAN class=\"tx\">" ; "" ];__LITBR____LITBR__ [ "</SPAN>" ; "" ];__LITBR____LITBR____LITBR__ [ "<A href=\"#\" onclick=\"return false\" onfocus=\"h()\" class=\"b\">" ; "" ];__LITBR__ [ "-</A>" ; "" ]__LITBR____LITBR__);__LITBR____LITBR___convertToTags = Substitute ( _removedHTMLTags; __LITBR__ [ "<" ; "<" ]; __LITBR__ [">" ; ">" ]; __LITBR__ [ " " ; " " ] __LITBR__ __LITBR__);__LITBR____LITBR___result = _convertToTags__LITBR__];__LITBR___result__LITBR__)__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/322__LITBR____LITBR__ Prototype: GetRealXMLFromWebViewer( _html )__LITBR__ Function Author: Andries Heylen (http://www.fmfunctions.com/mid/57)__LITBR__ Last updated: 17 February 2012__LITBR__ Version: 1.1__LITBR____LITBR__*/__LITBR__// ===================================
Comments
16 February 2012
17 February 2012
Andries
22 March 2012