DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
To replace an element with a copy of an existing element, use the existing element on the right side of an expression.
For example, the following line replaces the phoneNumber element for mydoc.employee.name[2] with the
phoneNumber element from mydoc.employee.name[1]:
<cfset mydoc.employee.name[2].phoneNumber=mydoc.employee.name[1].phoneNumber>
This code creates a true copy of the name[1].phoneNumber element as name[2].phoneNumber.
To move an element, assign it to its new location, then delete it from its old location. For example, the following lines
move the phoneNumber element from mydoc.employee.name[1] to mydoc.employee.name[2]:
<cfset mydoc.employee.name[2].phoneNumber=mydoc.employee.name[1].phoneNumber>
<cfset StructDelete(mydoc.employee.name[1], "phoneNumber")>
Note: You cannot copy or move an element from one document object to another document object.
Using XML and ColdFusion queries
You can convert XML documents into ColdFusion query objects and manipulate them using queries of queries. This
technique does not require the use of XPath and provides a method of searching XML documents and extracting data
that is natural to ColdFusion programmers.
Converting XML to a ColdFusion query
The following example reads an XML document, converts it to a query object, and then performs a query of queries
on the object to extract selected data:
Last updated 1/20/2012
1077