require 'rubygems'
require 'hpricot'

class AnalyticsXmlParser

  def initialize(file)
    @file = file
  end
  
  def parse
    doc = Hpricot.parse(@file.read)
    puts doc.search("//itemsummary[@id='PageviewsSummary']/summaryvalue").first.innerHTML.gsub(',','').to_s    
  end
  
end

file = File.open('/Users/cody/Projects/cakestreet_trunk/tmp/analytics.xml')
p = AnalyticsXmlParser.new(file)
p.parse()

=begin
/Users/cody/Projects/cakestreet_trunk/vendor/rails/railties/lib/commands/runner.rb:47: undefined method `filter[@[=]]' for #<Hpricot::Elem:0x302c350> (NoMethodError)
        from /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot/elements.rb:307:in `filter'
        from /Users/cody/Projects/cakestreet_trunk/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:250:in `find_all'
        from /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot/elements.rb:305:in `each'
        from /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot/elements.rb:305:in `find_all'
        from /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot/elements.rb:305:in `filter'
        from /usr/local/lib/ruby/gems/1.8/gems/hpricot-0.6/lib/hpricot/traverse.rb:310:in `search'
        from /Users/cody/Projects/cakestreet_trunk/lib/analytics_xml_parser.rb:12:in `parse'
        from /Users/cody/Projects/cakestreet_trunk/lib/analytics_xml_parser.rb:19
         ... 10 levels...
        from script/runner:3:in `eval'
        from /Users/cody/Projects/cakestreet_trunk/vendor/rails/railties/lib/commands/runner.rb:47
        from script/runner:3:in `require'
        from script/runner:3
=end