Adobe COLDFUSION 9 Manual page 1081

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
Deleting multiple elements
If an element has multiple children with the same name, use the
an element name to delete all of an element's child elements with that name. For example, both of the following lines
delete all name elements from the employee structure:
<cfset StructDelete(mydoc.employee, "name")>
<cfset ArrayClear(mydoc.employee.name)>
Use the
or
StructDelete
ArrayClear
example, each of the following lines deletes all child elements of the mydoc.employee.name[2] element:
<cfset StructDelete(mydoc.employee.name[2], "XmlChildren")>
<cfset ArrayClear(mydoc.employee.name[2].XmlChildren)>
Adding, changing, and deleting element attributes
You modify an element's attributes the same way you change the contents of any structure. For example, each of the
following lines adds a Status attribute the second mydoc.employee.name element:
<cfset mydoc.employee.name[2].XmlAttributes.Status="Inactive">
<cfset StructInsert(mydoc.employee.name[2].XmlAttributes, "Status", "Inactive")>
To change an attribute, use a standard assignment statement; for example:
<cfset mydoc.employee.name[2].XmlAttributes.Status="Active">
To delete an attribute, use StructDelete; for example:
<cfset StructDelete(mydoc.employee.name[1].XmlAttributes, "Status")>
Changing element properties
To change an element's properties, including its text and comment, use a standard assignment expression. For
example, use the following line to add "in the MyCompany Documentation Department" to the mydoc.employee XML
comment:
<cfset mydoc.employee.XmlComment = mydoc.employee.XmlComment & "in the
MyCompany Documentation Department">
Changing an element name
The XML DOM does not support changing an element name directly. To change the name of an element, create an
element with the new name, insert it into the XML document object before or after the original element, copy all the
original element's contents to the new element, and then delete the original element.
Clearing an element property value
To clear an element property value, either assign the empty string to the property or use the
For example, each of the following lines clears the comment string from mydoc.employee:
<cfset mydoc.employee.XmlComment = "">
<cfset StructDelete(mydoc.employee, "XmlComment")>
Replacing or moving an element
To replace an element with a new element, use a standard replacement expression. For example, to replace the
mydoc.employee.department element with a new element named organization, use either of the following lines:
<cfset mydoc.employee.department = XmlElemNew(mydoc, "Organization")>
<cfset mydoc.employee.XmlChildren[1] = XmlElemNew(mydoc, "Organization")>
StructDelete
function with
XmlChildren
Last updated 8/5/2010
function or
ArrayClear
to delete all of an element's child elements. For
StructDelete
1076
function with
function.

Advertisement

Table of Contents
loading

Table of Contents