I am working with ColdFusion/XML and would like to display restaurant names in my application. The problem is the restaurant names are part of the keywords field and are included with a list of foods the restaurant serves.
I would like to pull the restaurant name from the feed and display it in a list format
The XML feed above is simplified, and I have a few hundred of that kind of data to display. Luckily the restaurant name is always listed first in the keyword field followed by the food. How can pull and display the restaurant names only from the XML feed above?
Assuming that your xml comes allways in that form (the name of the restaurant being the first in the string and everything is separeted by ",") you can do it like this:
<cfscript> text = "Pizza Hut, pizza, cheese, garlic bread"; array = text.split(","); </cfscript>
The name of the restaurant will be in the array.
I dont know if the xml feed is done by you and i also dont know the context of your application but might be good to change it.
You're already on your way with XML, so use XML syntax:
<cfloop from="1" to="#arrayLen(eating.catalog.food)#" index="i">