XMLSearch supports the contains string function of XPath
August 18, 2008
ColdFusion 8 added improved support for XPath expressions. I've just discovered that you can now use the contains string function of XPath with XmlSearch!
Here's a simple example; imagine you wanted to find all the pizzas that use basil as an ingredient.
<cfxml variable="xmlobject">
<evening_menu>
<pizza>
<name>Margherita</name>
<ingredients>tomato, mozzarella, basil</ingredients>
</pizza>
<pizza>
<name>Capricciosa</name>
<ingredients>mozzarella, tomato, mushrooms, artichokes, ham, olives, egg</ingredients>
</pizza>
<pizza>
<name>Quattro Formaggi </name>
<ingredients>tomato, mozzarella, stracchino, fontina, gorgonzola, basil</ingredients>
</pizza>
</evening_menu>
</cfxml>
<cfdump var="#XmlSearch(xmlobject, "/evening_menu/pizza/ingredients[ contains(., 'basil' ) ] ")#" />
- Posted in:
- ColdFusion
4 comments
Leave a comment
If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)





Comment by Ben Nadel – August 18, 2008
Comment by Mike Rankin – August 18, 2008
@Mike, that's a great idea!
Comment by John Whish – August 19, 2008
Comment by James Beuthling – September 10, 2009