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]
.
Содержание COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...