Creates a ColdFusion XML document object that contains the markup in the tag body. This tag can include XML and CFML tags. ColdFusion processes the CFML code in the tag body, then assigns the resulting text to an XML document object variable.
<CFXML variable="xmlVarName" caseSensitive="yes" or "no">
IsXmlDoc,
IsXmlElement,
IsXmlRoot,
XmlChildPos,
XmlNew,
XmlParse,
XmlSearch,
XmlTransform
New in ColdFusion MX: This tag is new.
Attribute | Req/Opt | Default | Description |
---|---|---|---|
variable |
|
|
name of an xml variable |
caseSensitive |
Optional |
no |
|
An XML document object is represented in ColdFusion as a structure.
The following example creates a document object whose root element is MyDoc. The object includes text that displays the value of the ColdFusion variable testVar. The code creates four nested child elements, which are generated by an indexed cfloop
tag. The cfdump
tag displays the XML document object.
<cfset testVar = True>
<cfxml variable="MyDoc"> <MyDoc> <cfif testVar IS True> <cfoutput>The value of testVar is True.</cfoutput> <cfelse> <cfoutput>The value of testVar is False.</cfoutput> </cfif> <cfloop index = "LoopCount" from = "1" to = "4"> <childNode> This is Child node <cfoutput>#LoopCount#.</cfoutput> </childNode> </cfloop> </MyDoc> </cfxml> <cfdump var=#MyDoc#>