User Guide

Table Of Contents
Example: using XML in a ColdFusion application 873
<b>Full Price=</b> #priceQuery.totalPrice#<br>
<b>Discount Price=</b> #discountPrice#
</cfoutput>
<br><br>
<!---Generate an XML Receipt --->
<cfxml variable="receiptxml">
<receipt num = "34">
<cfoutput>
<price>#discountPrice#</price>
<cfif drate GT 0 >
<discountRate>#drate#</discountRate>
</cfif>
</cfoutput>
<itemsFilled>
<cfoutput query="orderQuery">
<name>#name# </name>
<qty> #qty# </qty>
<price> #qty*unitPrice# </price>
</cfoutput>
</itemsFilled>
</receipt>
</cfxml>
<!--- Display the resulting receipt --->
<cfdump var=#receiptxml#>
Reviewing the code
The following table describes the CFML code and its function. For the sake of brevity, it does not
include code that displays the processing results.
Code Description
<cffile action="read"
file="C:\CFusionMX7\wwwroot\examples\order.xml
"
variable="myxml">
<cfset mydoc = XmlParse(myxml)>
<cfset accountNum=#mydoc.order.
customer.XmlAttributes.accountNum#>
Reads the XML from a file and convert it to
an XML document object.
Sets the accountNum variable from the
customer entry’s accountnum attribute.