Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/http'
- require 'xml/libxml'
- require 'rubygems'
- require_gem 'activerecord'
- # require 'db_address.rb'
- ActiveRecord::Base.establish_connection(
- :adapter => "mysql",
- :username => "root",
- :host => "localhost",
- :password => "*****",
- :database => "mfinger_cms_db"
- )
- class Address < ActiveRecord::Base
- self.inheritance_column = "address";
- end
- class Filenname < ActiveRecord::Base
- self.inheritance_column = "filename";
- end
- Address.find(:all).each {|address| puts address.filename ; puts address.address }
- # Get the address to the xml document
- http_address = Net::HTTP.new(address.address, 80)
- response = http_address.get(address.filename, nil)
- if response.message == "OK"
- doc = XML::Document.file(response)
- root = doc.root
- puts "Collected prices: #{root.name}"
- elem3 = root.find('elem3').to_a.first
- puts "Elem3: #{elem3['attr']}"
- doc.find('//root_node/foo/bar').each do |node|
- puts "Node path: #{node.path} \t Contents: #{node}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement