From: Hans Meier Date: 2007-07-31T16:50:27+09:00 Subject: Re: parse xml file, put results in mysql db hi, i try the same code. there is a problem in the last line. but i dont understant why? NameError: undefined local variable or method `mobile_device_id' for RailsMaintainer:Class from ./script/../config/../config/../lib/rails_maintainer.rb:76:in `importContentDelivery' from (irb):1 contents.elements.each("MobileDevices/MobileDevice") { |element| puts element.attributes["id"] mobile_device_id = element.attributes["id"] } contents.elements.each("MobileDevices/MobileDevice") { |element| puts element.attributes["manufacturer"] manufacturer = element.attributes["manufacturer"] } contents.elements.each("MobileDevices/MobileDevice") { |element| puts element.attributes["model"] model = element.attributes["model"] } dbname="abo_development" m = Mysql.new("localhost", "root", "") dbh=DBI.connect("dbi:Mysql:abo_development:localhost", "root", "") m.select_db(dbname) sth=dbh.prepare("INSERT INTO mobile_devices (mobile_device_id,manufacturer,model) VALUES (?,?,?)") sth.execute("content.xml", "abo_development", "#{mobile_device_id}", "#{manufacturer}", "#{model}") -- Posted via http://www.ruby-forum.com/.