678
Chapter 31: Using XML and WDDX
•
Use associative array (bracket) notation to specify an element name that contains a period or
colon; for example,
myotherdoc.XmlRoot["Type1.Case1"]
.
•
You can use DOM methods in place of structure entry names.
For example, the following variables all refer to the
XmlText
value “Almanzo” in the XML
document created in
“A simple XML document” on page 671
:
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
“A simple XML document”
:
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
“Referencing the contents of an XML object” on page 677
apply to
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
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]
.
Summary of Contents for COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......