Using XmlSearch() In CFLoop Array (Thanks Scott Bennett!)

<!--- Create xml data. --->
<cfxml variable="xmlGirls">
 
	<girls>
 
		<brunette
			name="Maura Tierney"
			isactress="yes"
			/>
 
		<blonde
			name="Christina Cox"
			isactress="yes"
			/>
 
		<brunette
			name="Sarah Vivenzio"
			isactress="no"
			/>
 
		<blonde
			name="Jodie Foster"
			isactress="yes"
			/>
 
		<brunette
			name="Ashley Thomas"
			isactress="no"
			/>
 
	</girls>
 
</cfxml>
 
 
<p>
	<strong>Brunette Girls</strong>
</p>
 
<p>
	<!---
		Loop over all the returned xml nodes that are
		found at the following XPath value.
	--->
	<cfloop
		index="xmlGirl"
		array="#XmlSearch( xmlGirls, '//brunette' )#">
 
		#xmlGirl.XmlAttributes.name#
 
		<!--- Check to see if this girl is an actress. --->
		<cfif (
			StructKeyExists( xmlGirl.XmlAttributes, "isactress" ) AND
			xmlGirl.XmlAttributes.isactress
			)>
 
			[Actress]
 
		</cfif>
 
		<br />
 
	</cfloop>
</p>

For Cut-and-Paste