Browse the Ruby on Rails Community.

You are here: Forums Ask a Rails expert How to create array from xml d...

Replytotopic

How to create array from xml data

Posted in Forums : Ask a Rails expert

 
Profile

Authority 0
Posting Rating 44
Sign in to rate this post

Hi i have an xml and i want to crate array from this how to make array
sample of array is

<root> <deal> <deal_id> 1 </deal_id> <user_id> sfwafwa </user_id> <time> 1 </time> <description> 1 </description> </deal>
 
Me

Authority 62
Posting Rating 100
Sign in to rate this post

XML is a representation of a Hash, not an Array. You can use Hash.from_xml(your_xml_string) for that.

 
Profile

Authority 0
Posting Rating 44
Sign in to rate this post

HI Clemens I am using hash = Hash.from_xml(doc) I got full xml in hash form now i am trying to convert it in to array so i use hash.to_a a well known command but
The output is
{“time”=>”1”, “description”=>”1”, “deal_id”=>”1”, “user_id”=>”1”}
This is not an array
I need in this formet
<Show id: 70, domain_id: nil, show_name: nil, theme_id: nil, show_start: “2008-07-21 19:56:00”, show_end_time: “2008-07-21 21:37:00”, exhausted: false, filler_show: false, So how to do this

Replytotopic

Other Recent Topics

Ask a Rails expert : Ruby Builder

Ask a Rails expert : Better programming skills

Ask a Rails expert : Select Option

Ask a Rails expert : Updating ruby version on windows

Ask a Rails expert : Periodicall Ajax Calls and Session Expiry

Ask a Rails expert : Sub queries in RoR

Ask a Rails expert : Remembering associations

Ask a Rails expert : Keeping the databse clean

Ask a Rails expert : How to redirect single app to 2 different URLs

Ask a Rails expert : Dealing with nested models

Formatting Help
  • *bold*       _italics_      
    bq. (quotes)
  • "DSC":http://www.dsc.net
  • * or # (lists)
or cancel