ColdFusion 9.0 Resources |
XmlNewSee alsocfxml, IsXmlDoc, ToString, XmlFormat, XmlParse, XmlValidate; Using XML and WDDX in the Developing ColdFusion Applications Parameters
UsageAn 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. ExampleThe 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#> |