Create a XML feed into activerrecord database


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 imoprting 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


All you really need is Nokogiri for dealing with the XML. You can use Module: OpenURI (Ruby 2.1.1) 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 wrote in post #1146285:

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.