Listing 1

<?xml version="1.0"?>
<BEAN ID="1">
<BEAN_DESCRIPTION>Cubita Coffee is sun dried and hand sorted. It originates from an elevation of over 2000 meters in the Andes Mountains of Ecuador, which is located closest to the sun on the Equator. Superb aroma and rich Flavor.</BEAN_DESCRIPTION>
<BEAN ID="2">
<BEAN_NAME>Colombian Supremo</BEAN_NAME>
<BEAN_DESCRIPTION>This smooth, full-flavored coffee from Colombia boasts a sweet delicate aroma and a rich, balanced flavor. A classic coffee appropriate for any occasion.</BEAN_DESCRIPTION>
<BEAN ID="3">
<BEAN_NAME>Pure Kona Fancy</BEAN_NAME>
<BEAN_DESCRIPTION>Grown on the Big Island of Hawaii, this coffee is known for its tantalizing aroma. This medium bodied brew offers a rich flavor with subtle winery tones.</BEAN_DESCRIPTION>
<BEAN ID="4">
<BEAN_DESCRIPTION>The complex coffee from the highlands of East Africa features a winey, full flavor coupled with an intriguing aroma. A delightfully delicate selection for coffee lovers.</BEAN_DESCRIPTION>
<BEAN ID="5">
<BEAN_DESCRIPTION>Arabicas normally set aside for the demanding Northern European market produce this lively, well-balanced coffee distinguished by its snappy, clean taste. Try it!</BEAN_DESCRIPTION>
<BEAN ID="6">
<BEAN_NAME>Kona Peaberry</BEAN_NAME>
<BEAN_DESCRIPTION>Occasionally coffee fruit produces a single, rather than a double, bean. These "peaberries" provide all the flavor and aroma of their larger, regular cousins, but in a smaller package.</BEAN_DESCRIPTION>
<BEAN ID="7">
<BEAN_DESCRIPTION>The wonderful cocoa-like finish of this smooth, full-bodied coffee is reminiscent of rich, dark chocolate. Its unique characteristics can only be captured from the rich soils of this isle of Indonesia.</BEAN_DESCRIPTION>
<BEAN ID="8">
<BEAN_DESCRIPTION>25% Kona, 25% Sumatra and 50% Colombian. This combination unites the fragrant aroma of Kona with the full body of Sumatra and the dry snap of Colombian.</BEAN_DESCRIPTION>
<BEAN ID="9">
<BEAN_NAME>Kona Espresso</BEAN_NAME>
<BEAN_DESCRIPTION>Some like it dark roasted to give it the smokey, bittersweet tan that espresso drinkers crave.</BEAN_DESCRIPTION>
<BEAN ID="10">
<BEAN_NAME>Italian Roast</BEAN_NAME>
<BEAN_DESCRIPTION>Roasted in the Southern Italian tradition, this boldly flavored dark roast is a perfect choice for either a hearty cup of drip coffee or a shot of espresso. </BEAN_DESCRIPTION>

Listing 2

<!--- bean_list.cfm
Displays a list of coffee
beans from an XML file --->

<!--- Import the file from disk and parse into
an XML document object --->
<cffile action="READ" variable="xml"
<cfset xmlBeans=xmlParse(xml)>

<h1>Bean List</h1>

<!--- Set an Array reference to
Elements named "Bean" --->
<cfset aBeans=xmlBeans.Beans.Bean>

<!--- Start the HTML table --->
<table border="1">

<!--- Header Row --->
<tr bgcolor="aqua" valign="top">
<th>Bean Name</th>
<th>Bean Description</th>

<!--- Loop through the list of Bean elements
and output each Bean's name, description
and price --->
<cfloop from="1" to="#ArrayLen(aBeans)#" index="i">
<cfif i mod 2>
<cfset bgcolor="white">
<cfset bgcolor="silver">
<cfset id=aBeans[i].XmlAttributes.ID>
<cfset price=aBeans[i].Price_Per_Unit.XmlText>
<tr valign="top" bgcolor="#bgcolor#">
<td><a href="beans.cfm?id=#id#">
<td align="right">#DollarFormat(price)#</td>


Listing 3

Displays detail information about a single coffee bean
from an XML file

<!--- Import the file from disk and parse into XML doc object --->
<cffile action="READ" variable="xml"
<cfset xmlBeans=xmlParse(xml)>

<!--- Search for the one bean in URL.ID --->
<cfset aBeans=XmlSearch(xmlBeans, "//BEAN[@ID=#URL.ID#]")>

<!--- If we didn't get back a single bean, return to list --->
<cfif arrayLen(aBeans) neq 1>
<cflocation url="beans.cfm">

<!--- Output bean detail --->
<cfset Bean=aBeans[1]>
<p><a href="#cgi.script_name#">Back to List</a></p>

Listing 4

A file to call either the detail or list view,
depending on whether a Bean ID has been provided

<!--- Begin HTML Output --->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Coffee Bean Information</title>


<cfif IsDefined("URL.ID")>
<!--- If the user clicked on a single bean,
display detail info --->
<cfinclude template="bean_detail.cfm">
<!--- If the page was called without a click,
display a list of beans --->
<cfinclude template="bean_list.cfm">