XMLUnFormat(string)
Last updated November 15, 2002
Version: 1 | Requires: ColdFusion 5 | Library: StrLib
Description:
This is a simple UDF which does the exact opposite of CFMX's XmlFormat() function. Specifically, it replaces the following five characters in XML-escaped data with their normal equivalents:
> with >
< with <
' with '
" with "
& with &
Return Values:
Returns a string.
Example:
XmlSafe=""That's a very safe string & <TAG> you're it!!!"";
XmlUnsafe=XmlUnformat(XmlSafe);
WriteOutput(htmlCodeFormat(XmlUnsafe));
</cfscript>
Parameters:
| Name | Description | Required |
|---|---|---|
| string | String to format. | Yes |
Full UDF Source:
<cfscript>
/**
* UN-escapes the five forbidden characters in XML data.
*
* @param string String to format. (Required)
* @return Returns a string.
* @author Kreig Zimmerman (kkz@foureyes.com)
* @version 1, November 15, 2002
*/
function XMLUnFormat(string) {
var resultString=string;
resultString=ReplaceNoCase(resultString,"'","'","ALL");
resultString=ReplaceNoCase(resultString,""","""","ALL");
resultString=ReplaceNoCase(resultString,"<","<","ALL");
resultString=ReplaceNoCase(resultString,">",">","ALL");
resultString=ReplaceNoCase(resultString,"&","&","ALL");
return resultString;
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)