If you know exactly what the "name" of the limit is, you can use XPath for this. What you are looking for is a child of the "value" node of any terminal nodes where the name of the child node is "foo". In XPath, it looks like this:
'/data/limits/limit[name = 'foo']/value'
This will return an array of nodes (since there may be several matches), so we need to process the array. The whole example:
<cfset myXML = " <data> <limits> <limit> <name>foo</name> <value>bar</value> </limit> <limit> <name>foo2</name> <value>bar2</value> </limit> </limits> </data> "> <cfset XMLDOM = xmlParse(myXML)> <cfset nodeArray = xmlSearch(XMLDOM,"/data/limits/limit[name = 'foo']/value")> <cfloop array="#nodeArray#" index="thisNode"> <cfoutput>#thisNode.xmlText#</cfoutput> </cfloop>
source share