User Guide

Table Of Contents
854 Chapter 35: Using XML and WDDX
The rule for naming in case correct document objects, however, applies to the full reference string,
as indicated by the following caution:
Caution: Because ColdFusion always treats variable names as case insensitive, using dot notation
for element and attribute names in a case-sensitive XML document can generate unexpected results
(such as all-uppercase variable names), exceptions, or both. In case-sensitive XML documents, use
associative array notation or DOM notation names (such as XmlRoot or XmlChldren[2]).
Referencing the last element on the left side of an expression
The following rules apply to the meaning of the last component on the left side of an expression:
The component name is an element structure key name (XML property name), such as
XmlComment, ColdFusion sets the value of the specified element structure entry to the value of
the right side of the expression. For example, the following line sets the XML comment in the
mydoc.employee.name[1].first element to “This is a comment”:
mydoc.employee.name[1].first.XmlComment = "This is a comment";
If the component name specifies an element name and does not end with a numeric index, for
example
mydoc.employee.name, ColdFusion assigns the value on the right of the expression
to the first matching element.
For example, if both
mydoc.employee.name[1] and mydoc.employee.name[2] exist, the
following expression replaces
mydoc.employee.name[1] with a new element named address,
not an element named name:
mydoc.employee.name = XmlElemNew(mydoc, "address");
After executing this line, if there had been both mydoc.employee.name[1] and
mydoc.employee.name[2], there is now only one mydoc.employee.name element with the
contents of the original
mydoc.employee.name[2].
If the component name does not match an existing element, the element names on the left and
right sides of the expression must match. ColdFusion creates a new element with the name of
the element on the left of the expression. If the element names do not match, it generates an
error.
For example if there is no
mydoc.employee.name.phoneNumber element, the following
expression creates a new
mydoc.employee.name.phoneNumber element:
mydoc.employee.name.phoneNumber = XmlElemNew(mydoc, "phoneNumber");
The following expression causes an error:
mydoc.employee.name.phoneNumber = XmlElemNew(mydoc, "address");
If the component name does not match an existing element and the components parent or
parents also do not exist, ColdFusion creates any parent nodes as specified on the left side and
use the previous rule for the last element. For example, if there is no
mydoc.employee.phoneNumber element, the following expression creates a phoneNumber
element containing an AreaCode element:
mydoc.employee.name.phoneNumber.AreaCode = XmlElemNew(mydoc, "AreaCode");