Ticket #145 (new defect)
XPath and undefined method `filter[@[=]]'
| Reported by: | gonzoprosperity | Owned by: | why |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | ext/hpricot_scan | Version: | |
| Keywords: | Cc: |
Description
I am trying to parse an XML file generated by Google Analytics. When I run my script from a bare-bones ruby script it works just fine, but when I take the same logic and try running it under a Rails app (either via an HTTP request, script/runner OR script/console) I get a stack dump.
My XPath is:
doc.search("//itemsummary[@id='PageviewsSummary?']/summaryvalue")
And the stack trace is:
/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
Attached is my basic Ruby script with the XPath (and the above stack trace)
Thanks in advance.
