XMLFormat

Formats a string so that special XML characters can be used as text in XML

Method Signature

XMLFormat(string=[string], escapeChars=[boolean])

Arguments

Argument
Type
Required
Description
Default

string

string

true

The string to format

escapeChars

boolean

false

whether to escape additional characters restricted as per XML standards. For details, see http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-RestrictedChar.

false

Examples

Basic xmlFormat() usage

In this example we demonstrate passing the invalid characters < and & into the xmlFormat() function to make them XML safe.

Run Example

writeOutput( xmlFormat( "<node>Good &amp; Juicy</node>" ) );

Result: <node>Good &amp; Juicy</node>

Additional Examples

Run Example

string = "I like peanut butter & jelly.";
dump( XmlFormat( string ) );
 // I like peanut butter &amp; jelly.

Last updated

Was this helpful?