Skip to content

Instantly share code, notes, and snippets.

@fizx
Created January 15, 2009 21:14
Show Gist options
  • Save fizx/47625 to your computer and use it in GitHub Desktop.
Save fizx/47625 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "rubygems"
require "dexterous"
require "pp"
file = ARGV.shift
unless file
puts "Usage: #{$0} FILE ID [ID2, ...]"
exit 1
end
query = ARGV.inject({}) do |memo, arg|
memo["#{arg}(//location/[objid='#{arg}'])"] = {
"name" => "Name",
"address" => "Address",
}
memo
end
dex = Dexterous.new(query)
pp dex.parse(:file => file, :input => :xml)
# 111:~ kyle$ ruby locquery.rb locations_nyv.xml 669491 669502
# {"669502"=>
# {"name"=>"PJ Clarke's", "address"=>"44 W 63rd St. | Lincoln Square"},
# "669491"=>{"name"=>"Peep", "address"=>"177 Prince St."}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment