GetRealXMLFromWebViewer ( )

Function stats

Average user rating
5.0000
57
322
9999
Support
FileMaker 8.5 +
Date posted
16 February 2012
Last updated
17 February 2012
Version
Recursive function
No

Author Info
 Andries Heylen

10 functions

Average Rating 4.9

author_avatar



 

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;
    [ "&lt;" ; "<" ];
    ["&gt;" ; ">" ];
    [ "&nbsp;" ; " " ]
    
);

_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

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

 

Comments

CamelCase data
16 February 2012



You may want to update this to handle iOS... currently iOS is treated as Windows. Which is not a nice thing do to an OS!
 Bug report
Andries Heylen
17 February 2012



adapted the code. Thanks !

Andries
  General comment
Fabrice
22 March 2012



Great stuff ! thanks !
  General comment
JerryAPowers
17 July 2013



I have used this custom function successfully in my application. However, I just upgraded to Filemaker Pro 12 Advanced and it appears that this function no longer works. Is there an update to this function that works in 12, or did Filemaker add a function that replaces this?
 Bug report