CFXML |
Description
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.
Category
Extensibility tags

Syntax

    <CFXML
       variable="xmlVarName"
       caseSensitive="yes" or "no">

See also
IsXmlDoc, IsXmlElem, IsXmlRoot, XmlChildPos, XmlNew, XmlParse, XmlSearch, XmlTransform
History
ColdFusion MX: Added this tag.
Usage
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.

Note: | Do not include an <?xml ?> processing directive in the cfxml tag body. This directive is not required for processing, and causes an error. To process XML text that includes this directive, use the XmlParse function.

Example

    <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#>

VARIABLE |
Name of an xml variable

CASESENSITIVE |
| Optional

Default value: "no"

- yes: maintains the case of document elements and attributes
- no