Assigning Data To An Xml Object - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Use associative array (bracket) notation to specify an element name that contains a period or
colon; for example,
You can use DOM methods in place of structure entry names.
For example, the following variables all refer to the
document created in
mydoc.XmlRoot.XmlChildren[1].XmlChildren[1].XmlText
mydoc.employee.name[1].first.XmlText
mydoc.employee.name[1]["first"].XmlText
mydoc["employee"].name[1]["first"].XmlText
mydoc.XmlRoot.name[1].XmlChildren[1]["XmlText"]
The following variables all refer to the EmpType attribute of the first name element in the XML
document created in
mydoc.employee.name[1].XmlAttributes.EmpType
mydoc.employee.name[1].XmlAttributes["EmpType"]
mydoc.employee.XmlChildren[1].XmlAttributes.EmpType
mydoc.XmlRoot.name[1].XmlAttributes["EmpType"]
mydoc.XmlRoot.XmlChildren[1].XmlAttributes.EmpType
Neither of these lists contains a complete set of the possible combinations that can make up a
reference to the value or attribute.

Assigning data to an XML object

When you use an XML object reference on the left side of an expression, the preceding rules apply
to the reference up to the last element in the reference string.
For example, the rules in
mydoc.employee.name[1].first in the following expression:
mydoc.employee.name[1].first.MyNewElement = XmlElemNew(mydoc, NewElement);
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
, ColdFusion sets the value of the specified element structure entry to the value of
XmlComment
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
to the first matching element.
For example, if both
following expression replaces
not an element named name:
mydoc.employee.name = XmlElemNew(mydoc, "address");
After executing this line, if there had been both
mydoc.employee.name[2]
contents of the original
678
Chapter 31: Using XML and WDDX
myotherdoc.XmlRoot["Type1.Case1"]
"A simple XML document" on page
"A simple XML
document":
"Referencing the contents of an XML object" on page 677
, ColdFusion assigns the value on the right of the expression
mydoc.employee.name[1]
mydoc.employee.name[1]
, there is now only one
mydoc.employee.name[2]
.
value "Almanzo" in the XML
XmlText
671:
and
mydoc.employee.name[2]
with a new element named address,
mydoc.employee.name[1]
mydoc.employee.name
.
apply to
exist, the
and
element with the

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion mx

Table of Contents