Create a XML feed into activerrecord database

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

On Fri, May 16, 2014 at 4:10 AM, Sayth R. [email protected]
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/rdoc/OpenURI.html 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 S. ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

Hassan S. wrote in post #1146285:

On Fri, May 16, 2014 at 4:10 AM, Sayth R. [email protected]
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/rdoc/OpenURI.html 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 S. ------------------------ [email protected]
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?

On Fri, May 16, 2014 at 5:03 PM, Sayth R. [email protected]
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 S. ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs