Adobe COLDFUSION 9 Manual page 1072

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
When you retrieve data from the document object, references to XmlCdata and XmlText return the same string.
The following example shows how ColdFusion handles CDATA text:
<cfscript>
myCDATA = "This is CDATA text";
MyDoc = XmlNew();
MyDoc.xmlRoot = XmlElemNew(MyDoc,"myRoot");
MyDoc.myRoot.XmlChildren[1] = XmlElemNew(MyDoc,"myChildNodeCDATA");
MyDoc.myRoot.XmlChildren[1].XmlCData = "#myCDATA#";
</cfscript>
<h3>Assigning a value to MyDoc.myRoot.XmlChildren[1].XmlCdata.</h3>
<cfoutput>
The type of element MyDoc.myRoot.XmlChildren[1] is:
#MyDoc.myRoot.XmlChildren[1].XmlType#<br>
The value when output using XmlCdata is: #MyDoc.myRoot.XmlChildren[1].XmlCData#<br>
The value when output using XmlText is: #MyDoc.myRoot.XmlChildren[1].XmlText#<br>
</cfoutput>
<br>
The XML text representation of Mydoc is:
<cfoutput><XMP>#tostring(MyDoc)#</XMP></cfoutput>
<h3>Assigning a value to MyDoc.myRoot.XmlChildren[1].XmlText.</h3>
<cfset MyDoc.myRoot.XmlChildren[1].XmlText = "This is XML plain text">
<cfoutput>
The value when output using XmlCdata is: #MyDoc.myRoot.XmlChildren[1].XmlCData#<br>
The value when output using XmlText is: #MyDoc.myRoot.XmlChildren[1].XmlText#<br>
</cfoutput>
<br>
The XML text representation of Mydoc is:
<cfoutput><XMP>#tostring(MyDoc)#</XMP></cfoutput>
Creating and saving an XML document object
You can use several methods to create and save an XML document object. The specific technique that you use depends
on the application and your coding style.
Creating an XML document object using the cfxml tag
The
tag creates an XML document object that consists of the XML markup in the tag body. The tag body can
cfxml
include CFML code. ColdFusion processes the CFML code and includes the resulting output in the XML. The
following example shows a simple
tag:
cfxml
Last updated 8/5/2010
1067

Advertisement

Table of Contents
loading

Table of Contents