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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try using Nokogiri: http://nokogiri.org/ It''s a great and easy to use parser. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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): http://github.com/kete/kete/blob/master/lib/workers/excel_based_importer_worker.rb - starting around line 30, note the hardcoding of element names that you need to adjust 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 On Tue, Mar 16, 2010 at 2:54 AM, WSzP <ctdd-6nYcUAqTnno@public.gmane.org> wrote:> Try using Nokogiri: http://nokogiri.org/ It''s a great and easy to use > parser. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Mar 16, 2010 at 3:09 PM, Burguer Burg <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 XMLI''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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.