Select Any XML Node With A Given Value Using ColdFusion And XPath

<!--- Build an XML document object. --->
<cfxml variable="xmlData">
 
	<root>
		<a1>Meep</a1>
		<a2>Meep</a2>
		<a3>
			<b1>Dink</b1>
			<b2>Meep</b2>
		</a3>
		<a4>Blam</a4>
	</root>
 
</cfxml>
 
 
<!---
	Get all nodes in the XML document that have the
	child text node, "Meep". We don't care where the
	node is or they are related... we only care about
	this inner text value.
--->
<cfset arrNodes = XmlSearch(
	xmlData,
	"//*[ text() = 'Meep' ]"
	) />
 
<!--- Dump out results. --->
<cfdump
	var="#arrNodes#"
	label="All Nodes By Text Value"
	/>

For Cut-and-Paste