Formatting for XML

When you have to format C/AL variables (numbers, dates/times, booleans) for exchange with other apps, call FORMAT(variable,0,9) instead of simply FORMAT(variable). The format 9 formats the variable according to XML standards, and this value can then be interpreted correctly on any system with any regional settings. This is useful also when passing string-formatted values from C/AL to C# or JavaScript.

Vjeko

Vjeko has been writing code for living since 1995, and he has shared his knowledge and experience in presentations, articles, blogs, and elsewhere since 2002. Hopelessly curious, passionate about technology, avid language learner no matter human or computer.

This Post Has 3 Comments

  1. BvB

    Use this function to replace the escape characters like the Ampersand.

    PROCEDURE XMLEscape@11154653(Text@11154640 : Text) : Text;
    VAR
    Escape@11154643 : DotNet “‘mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Security.SecurityElement”;
    BEGIN
    EXIT(Escape.Escape(Text));
    END;

Leave a Reply