Skip to content

Instantly share code, notes, and snippets.

@warlley
Created August 3, 2010 03:09
Show Gist options
  • Save warlley/505762 to your computer and use it in GitHub Desktop.
Save warlley/505762 to your computer and use it in GitHub Desktop.
require 'nokogiri'
doc = Nokogiri::XML(File.open('/home/felipe/banco_belasoft.xml', 'r'))
doc.search('ROOT//row').each do |c|
MyCustomerModel.create (
:old_code => c.search('field[@name="codigo"]').text,
:name => c.search('field[@name="nome"]').text,
:gender => c.search('field[@name="sexo"]').text,
:birth => c.search('field[@name="data_nascimento"]').text,
:address => c.search('field[@name="endereco"]').text,
:neighborhood => c.search('field[@name="bairro"]').text,
:postal_code => c.search('field[@name="cep"]').text,
:city => c.search('field[@name="cidade"]').text
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment