Forum: Ruby on Rails Create a XML feed into activerrecord database

73a86b3136bfdda99045ba5de86dd9ec?d=identicon&s=25 Sayth Renshaw (flebber)
on 2014-05-16 13:10
Hi

I am trying to gather some information so I can learn what I need to do.
My goal is to download an xml file from a sporting body, clean the file
to remove useless/uneeded info and then consistently update it into the
database to display on my site.

Since the XML will only update a subset of my database tables, I am
wondering how I create a consistent and reliable method of importing the
data into my database.

I am using nokogiri at the moment to play around with editing files, but
what format and what requirements and tools do I need to acheive this?

Thank you

Sayth
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2014-05-16 15:50
(Received via mailing list)
On Fri, May 16, 2014 at 4:10 AM, Sayth Renshaw <lists@ruby-forum.com>
wrote:

> what format and what requirements and tools do I need to acheive this?
All you really need is Nokogiri for dealing with the XML. You can use
http://ruby-doc.org/stdlib-2.1.1/libdoc/open-uri/r... to
fetch the file.

Do you want to just store the raw XML, or use the data in it to create
model objects to persist? If you want "consistent and reliable" the
latter may be best since you can use validations on your imported
data.

Good luck,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
73a86b3136bfdda99045ba5de86dd9ec?d=identicon&s=25 Sayth Renshaw (flebber)
on 2014-05-17 02:03
Hassan Schroeder wrote in post #1146285:
> On Fri, May 16, 2014 at 4:10 AM, Sayth Renshaw <lists@ruby-forum.com>
> wrote:
>
>> what format and what requirements and tools do I need to acheive this?
> All you really need is Nokogiri for dealing with the XML. You can use
> http://ruby-doc.org/stdlib-2.1.1/libdoc/open-uri/r... to
> fetch the file.
>
> Do you want to just store the raw XML, or use the data in it to create
> model objects to persist? If you want "consistent and reliable" the
> latter may be best since you can use validations on your imported
> data.
>
> Good luck,
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> http://about.me/hassanschroeder
> twitter: @hassan

Yes I want to create model objects to persist. I will have other objects
for user input. So I create a DOM to map to the database objects I want
to be updating via the XML?
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2014-05-17 02:21
(Received via mailing list)
On Fri, May 16, 2014 at 5:03 PM, Sayth Renshaw <lists@ruby-forum.com>
wrote:

> Yes I want to create model objects to persist. I will have other objects
> for user input. So I create a DOM to map to the database objects I want
> to be updating via the XML?

Not sure what you mean by "create a DOM"; you'd use Nokogiri to
extract the values you need from the XML, and then use those to
build instances of the objects you want to save.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.