Forum: Rails deployment Store data in db from XML

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6cd7e03644176cfa8ca0688075457f1d?d=identicon&s=25 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....
Ac4123f7af05808b1ec7a1bbdb69ce07?d=identicon&s=25 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
72084b8576fa49305c7f858ca29d0b24?d=identicon&s=25 Todd Fox (foxxx)
on 2010-03-04 03:07
5535295c69d23b872494f6b137badf4d?d=identicon&s=25 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.
This topic is locked and can not be replied to.