Creates an XML document object.


An empty XML document object.


XML functions

Function syntax


See also

cfxml, IsXmlDoc, ToString, XmlFormat, XmlParse, XmlValidate; Using XML and WDDX in ColdFusion MX Developer's Guide


ColdFusion MX: Added this function.


Parameter Description


Determines how ColdFusion processes the case of XML document object component identifiers:

  • True: maintains case
  • False: ColdFusion ignores case. Default.


An XML document object is represented in ColdFusion as a structure.

The caseSensitive parameter value determines whether identifiers whose characters are of varying case, but are otherwise the same, refer to different components; for example:

If your XML object is case sensitive, you cannot use dot notation to reference an element or attribute name. Use the name in associative array (bracket) notation, or a reference that does not use the case-sensitive name (such as xmlChildren[1]) instead. In the following code, the first line will work with a case-sensitive XML object. The second and third lines cause errors:

MyDoc.xmlRoot.XmlAttributes["Version"] = "12b";
MyDoc.xmlRoot.XmlAttributes.Version = "12b";
MyDoc.MyRoot.XmlAttributes["Version"] = "12b";

To convert an XML document object into a string, use the ToString function.


The following example creates and displays a ColdFusion document object:

<cfset testVar = True>
   MyDoc = XmlNew();
   MyDoc.xmlRoot = XmlElemNew(MyDoc,"MyRoot");
   if (testVar IS TRUE)
      MyDoc.MyRoot.XmlText = "The value of testVar is True.";
      MyDoc.MyRoot.XmlText = "The value of testVar is False.";
   for (i = 1; i LTE 4; i = i + 1)   {
      MyDoc.MyRoot.XmlChildren[i] = XmlElemNew(MyDoc,"childNode");
      MyDoc.MyRoot.XmlChildren[i].XmlText = "This is Child node " & i &".";
<cfdump var=#MyDoc#>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7