I am parsing an xml result using Hpricot, amazing ..
I have a serie of tags to be transformed as parameters, so I am
building Hash by looping on these tags , the resulting data is oK? but
I ma not sure that I wrote a dry code

.......
        if doc.search('response > error').innerHTML.empty?
          accountTypes = []
          (doc/:accounttype).each do |accountType|
            data = {}
....
            data[:locale] =
(accountType/:localized/:locale/:code).innerHTML
            data[:title] =
(accountType/:localized/:locale/:title).innerHTML
....
... # here is the loop over the <tags> elements
           tags = {}
           (accountType/:tag).each do |tag|
             key = (tag/:name).innerHTML.to_s
             value = (tag/:value).innerHTML.to_s
             tags.store(key, value)
           end
.....# end of the loop , storing the data
            data[:tags] = tags
           accountTypes << data
           end

Is this loop OK ?
           tags = {}
           (accountType/:tag).each do |tag|
             key = (tag/:name).innerHTML.to_s
             value = (tag/:value).innerHTML.to_s
             tags.store(key, value)
           end

thanks for you fedback

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to