Just an example of how you'd output it in a view, I'm sure you can
adapt it from there to extract whatever values you want:

<% @parsed_response[0]['searchresults']['category'].each do |cat| %>
  <h1><%=h cat['name']%></h1>
  <p>
    <h3>Foods</h3>
    <% cat['foods']['food'].each do |food| %>
      <p><%=h food['id']%> - <%=h food['display']%></p>
    <% end %>
  </p>
<% end %>

On Aug 26, 3:01 pm, Zack Nathan <[email protected]> wrote:
> Frederick Cheung wrote:
> > On Aug 26, 1:32 pm, Zack Nathan <[email protected]> wrote:
> >> Ok So I am using the calorieking api and it crack as my xml parser (it
> >> comes with httparty which is my consumer gem). Now I need to be able to
> >> list the food names. How can i get data from a hash that contains
> >> arrays? Here is what the hash looks like when pp'ed.
>
> > I'm not entirely sure what you're asking. Iterate over the hash and
> > the arrays it contains with something like each ?
>
> > Fred
>
> Well Ideally Id like to know how to get all the displays. Now Whether i
> need to iterate through it or i can just use a command to get them, im
> not sure. In a more broad sense i need to know how to get any element,
> so perhaps a display or an id.
>
> Many thanks,
>
> jakx12
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to