hi, can someone help me with this after i read theres nothing show in my database.... wat happen...? where is my error in my code??
class Map
require 'rexml/document' require "mysql" require "dbi" include REXML scanfile = File.new('River_Va.lmx') doc = doc = File.open('River_Va.lmx', 'rb') {|scanfile| Document.new(scanfile) } puts doc
maps = REXML::Document.new() root = maps.root
names = latitudes = longtitudes =
#~ MSISDN = {} #~ mobils.elements.each("MobileDevices/MobileDevice") { |element| puts #~ element.attributes["MSISDN"] #~ MSISDN = element.attributes["MSISDN"] }
#~ datetime = {} #~ mobils.elements.each("MobileDevices/MobileDevice") { |element| puts #~ element.attributes["datetime"] #~ datetime = element.attributes["datetime"] }
#~ description = {} #~ mobils.elements.each("MobileDevices/MobileDevice") { |element| puts #~ element.attributes["description"] #~ description = element.attributes["description"] }
maps.elements.each("lm:landmark") { |element| puts element.attributes["name"] names.push element.attributes["name"] name = element.attributes["name"]}
puts name maps.elements.each("lm:landmark") { |element| puts element.attributes["latitude"] latitudes.push element.attributes["latitude"]}
puts latitudes maps.elements.each("lm:longitude") { |element| puts element.attributes["longtitude"] longtitudes.push element.attributes["longtitude"] }
puts longtitudes
# db insert dbname="email_development"
m = Mysql.new("localhost", "root", "", "email_development") sth=m.query("insert into maps (name,latitude,longtitude) values (name,latitude,longtitude)") #~ ("INSERT INTO Maps (name, latitude, #~ longtitude) #~ VALUES (?,?,?,?,?)") #~ models.each_index do |index| #~name = names[index] #~ latitude = latitudes[index] #~ longtitude = longtitudes[index] # sth.execute("River_Va.lmx", "email_development", "#{names}", #"#{latitudes}", "#{longtitudes}") #end
end
this is my xml file~~
<?xml version="1.0" encoding="UTF-8"?> <lm:lmx xmlns:lm="http://www.nokia.com/schemas/location/landmarks/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nokia.com/schemas/location/landmarks/1/0 lmx.xsd"> <lm:landmarkCollection> <lm:landmark> <lm:name>River Valley High School</lm:name> <lm:coordinates> <lm:latitude>9.36</lm:latitude> <lm:longitude>147.804</lm:longitude> </lm:coordinates> <lm:addressInfo> <lm:country>Singapore</lm:country> <lm:city>Singapore</lm:city> <lm:postalCode>10</lm:postalCode> <lm:district>Bukit Merah</lm:district> <lm:street>Malan Road</lm:street> <lm:phoneNumber>+65987987987</lm:phoneNumber> </lm:addressInfo> </lm:landmark> </lm:landmarkCollection> </lm:lmx>