View comments | RSS feed

XmlFormat

Description

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

Return value

A copy of string that is safe to use with XML.

Category

Extensibility functions, String functions, XML functions

Syntax

XmlFormat(string)

See also

cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlNew, XmlParse, XmlSearch, XmlTransform

History

New in ColdFusion MX: this function is new.

Parameters

Parameter Description
string
A string or a variable that contains one

Usage

The characters that this function escapes include the following:

Example

<h3>XMLFormat</h3>
<p>This example shows how XMLFormat is used to escape special 
XML characters and make the use of XML with ColdFusion easy.</p>
<XMP>
<?xml version = "1.0"?> 
<cfoutput>
<someXML>
  <someElement someAttribute = "#XMLFormat("'a quoted value'")#> 
    #XMLFormat(  "Body of element to be passed here.")#
  </someElement>
</someXML>  
</cfoutput>
</XMP>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


AlanA said on Sep 21, 2004 at 2:06 PM :
XMLFormat function does not correctly escape illegal characters.

For example: When quering a db table with a field of TITLE....
<cfoutput query="GetArticles">
<item>
<title>#XMLFormat("Title")#</title>
</cfoutput>

The XMLFormat function does not correctly escape the high bit code " character and therefore the resulting XML will not vaildate.

Instead, the validator at http://www.feedvalidator.org/ responds:

Your feed appears to be encoded as "UTF-8", but your server is reporting "US-ASCII"
line 42, column 9: 'utf8' codec can't decode byte 0x93 in position 1344: unexpected code byte (maybe a high-bit character?)

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt2120.htm