Ok,
So I have a program that uses REXML. It works. I have working code.
But I think something in rexml changed and now my code is broken.
Either that or my code is broken in such a way that I cannot figure out
the problem.
What I’m doing is storing xml files then loading the data into an
object. The code is equivalent to this.
require 'rexml/document’
include REXML
cfg = File.new( “configfile.xml” )
config = Document.new( cfg )
myObj = myObject.new( config.elements[ “//idtag” ] )
If I try just doing
print config.elements[ “//idtag” ]
I get the same error. so it must be caused by something in the Document
object, maybe its not being made right? Here is the backtrace.
/usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:75:in internal_parse': undefined method
node_type’ for #REXML::Element:0x40425edc
(NoMethodError)
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:73:in
delete_if' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:73:in
internal_parse’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:51:in match' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:303:in
d_o_s’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:301:in
each_index' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:301:in
d_o_s’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:294:in
descendant_or_self' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:220:in
internal_parse’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:51:in match' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:34:in
parse’
from /usr/lib/ruby/site_ruby/rexml/xpath.rb:28:in first' from /usr/lib/ruby/site_ruby/1.8/rexml/element.rb:844:in
[]’
It says that node_type is undefined. However, if I look in
/usr/lib/ruby/site_ruby/rexml/element.rb I can plainly see that
node_type is indeed defined. I triple checked the XML to make sure it
was valid. And no matter which xpath I use it still breaks. Ideas anyone?
-Scott