Forum: Rails deployment Store data in db from XML

Posted by Smit Shah (smit_shah)
on 2009-09-29 13:00
Hi All...

I am trying to parsing data from XML. But I am not able to store it in
database.
Anyone have any idea about that???

Thanks in advance....
Posted by Priyanka Pathak (priyanka-pathak)
on 2009-11-07 07:09
Smit Shah wrote:
> Hi All...
> 
> I am trying to parsing data from XML. But I am not able to store it in
> database.
> Anyone have any idea about that???
> 
> Thanks in advance....

Hi smit,
        As you parse the xml data using feednormalizer gem. so you get 
it's result in hash. now running loop for that hash, you are able to 
store xml data to your table. look below code, hope it's solve your 
problem.

 @rss = FeedNormalizer::FeedNormalizer.parse open(feed_url)

 if !@rss.entries.blank?
  for rss in @rss.entries
    @record = Model.new
    @record.url = rss.url
    Same way fill other attributes.. in that table
    @record.save
  end
 end

Thanks,
Priyanka Pathak
Posted by Todd Fox (foxxx)
on 2010-03-04 03:07
you could also use rexml

http://www.germane-software.com/software/rexml/docs/tutorial.html
Posted by Andola Soft (andolasoft)
on 2010-10-12 15:41
rexml is a gem which can be used to parse xml into the DB dynamically. 
you have to first store the xml into an array and then use for loop and 
insert function to store in mysql.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.