On Sat, Feb 12, 2011 at 9:25 AM, Norbert Melzer
<[email protected]> wrote:
>> OK, now I tried the following
>>      b = Hash.new(Array.new)
>>      h = XmlSimple.xml_in self.raw
>>      h["data"][0]["bank"][0]["item"].each do |item|
> delete line>        if b.key? item["cat"]
> add line>        if !b.key? item["cat"]
>>          b[item["cat"]] = item
>>        else
>>          b[item["cat"]] << item
>>        end
>>      end
>>
>>      pp b.keys
>
> call me stupid... But with above marked change it works as I want it
> to behave :D


try this,

b = Hash.new {|h,k| h[k]=[]}
h = XmlSimple.xml_in self.raw

h["data"][0]["bank"][0]["item"].each do |item|
  b[item["cat"]] << item
end

best regards -botp

-- 
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