xmlFormat

Escapes XML special characters in a string, so that the string is safe to use with XML.

xmlFormat(String [, escapeChars]) → returns string

Discouraged: Adobe recommends using encodeForXML instead of xmlFormat.

Argument Reference

String string
Required

The string to escape

escapeChars boolean

When true escapes restricted characters according to the W3C XML standard.

Examples
Sample code invoking the xmlFormat function

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

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

Expected Result: &lt;node&gt;Good &amp;amp; Juicy&lt;/node&gt;

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub