[BUG?] NoMethodError in REXML::Xpath.match in Ruby 1.9

  • Thread starter Alexey Verkhovsky
  • Start date
A

Alexey Verkhovsky

I have a problem matching a single-tag XML to paths like '/something',
illustrated by the following shell session quote. Who is at fault here -
myself or rexml?

[alex@dhcp-89-2 test-report]$ ruby -v
ruby 1.9.0 (2004-07-31) [i686-linux]
[alex@dhcp-89-2 test-report]$ irb -v
irb 0.9(02/07/03)
[alex@dhcp-89-2 test-report]$ irb
irb(main):001:0>

irb(main):011:0> xml = REXML::Element.new('element attr="aaa"')
=> <element attr="aaa"/>
irb(main):012:0> REXML::XPath.match(xml, '/*')
NoMethodError: undefined method `node_type' for nil:NilClass
from /usr/local/lib/ruby/1.9/rexml/xpath_parser.rb:124:in
`internal_parse'
from /usr/local/lib/ruby/1.9/rexml/xpath_parser.rb:123:in `each'
from /usr/local/lib/ruby/1.9/rexml/xpath_parser.rb:123:in
`internal_parse'
from /usr/local/lib/ruby/1.9/rexml/xpath_parser.rb:49:in `match'
from /usr/local/lib/ruby/1.9/rexml/xpath_parser.rb:34:in `parse'
from /usr/local/lib/ruby/1.9/rexml/xpath.rb:59:in `match'
from (irb):12
from /usr/local/lib/ruby/1.9/rexml/text.rb:250

Best regards,
Alexey Verkhovsky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,233
Latest member
AlyssaCrai

Latest Threads

Top