hi guys can somebody help to find some tutorial or link to find the way
to import an external XML file to rails with some nodes and child-nodes.
Thanks
hi guys can somebody help to find some tutorial or link to find the way
to import an external XML file to rails with some nodes and child-nodes.
Thanks
What are you after? The answer really depends on your situation.
Two options come to mind:
A custom rake task. You can see a simple example here that uses YAML
instead of XML as source data:
http://github.com/kete/kete/blob/master/lib/tasks/user_export_import.rake
Here’s an example of parsing from source XML (modify this and replace
the YAML parsing the above rake task):
Another option, if you have already created a RESTful interface that
accepts XML for creating new records, you might simply create a script
that parses your existing XML file and submits a POST to your create
action with the relevant data. Not necessarily the fastest process,
but if it is a one off import it might be the quickest thing to put
together programming wise. Net::HTTP and Nokogiri seem like all you
really need.
I would probably just go with the rake task. Pretty simple.
Cheers,
Walter
Thanks a lot for your help i’ll try with thats options
have you guys ever used the "Hash.from_xml " method to import XML
thanks for the help i really really appreciate
On Tue, Mar 16, 2010 at 3:09 PM, Burguer B. [email protected]
wrote:
Thanks a lot for your help i’ll try with thats options
have you guys ever used the "Hash.from_xml " method to import XML
I’ve used it in the past. If you aren’t importing a huge amount of
records it might be ok. Otherwise I think you are better off using
Nokogiri. Depends on the complexity of your source XML.
Cheers,
Walter
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs