Description
Creates an XML document object.
Returns
An empty XML document object.
Creates an XML document object.
An empty XML document object.
XmlNew([caseSensitive])
cfxml, IsXmlDoc, ToString, XmlFormat, XmlParse, XmlValidate; Using XML and WDDX in the Developing ColdFusion Applications
ColdFusion MX: Added this function.
Parameter |
Description |
---|---|
caseSensitive |
Determines how ColdFusion processes the case of XML document object component identifiers:
|
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 False, these names refer to the same elements or attributes.
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 xmlChildren1) 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> <cfscript> MyDoc = XmlNew(); MyDoc.xmlRoot = XmlElemNew(MyDoc,"MyRoot"); if (testVar IS TRUE) MyDoc.MyRoot.XmlText = "The value of testVar is True."; else 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 &"."; } </cfscript> <cfdump var=#MyDoc#>