[Instantrails-users] REXML question
bill.walton at charter.net
Sat Apr 29 10:20:00 EDT 2006
Hi Curt, Gavin;
Thanks for your replies. I've tried both suggestions and, unfortunately, it still gives me errors. I'd really appreciate it if you'd take a look at the irb input / output below and tell me if you can tell what I'm doing wrong. Thanks!
--------------- irb session ---------------
irb(main):001:0> require "rexml/document"
irb(main):003:0> doc=REXML::Document.new file
=> <UNDEFINED> ... </>
[BW] I assume the <UNDEFINED> error message above is referring to Document. One thing I don't understand though is why the 'require' on the first line of input is successful since rexml/document.rb is over in another branch of the directory tree. For now, I'm just assuming irb knows where to find what it needs. It returns true, so I figure it found it. But if irb found document.rb, then why is the 'doc=' line failing?
[BW] So I figured I'd give Gavin's approach a shot.
irb(main):004:0> include REXML
irb(main):005:0> doc = Document.new file
NoMethodError: undefined method `' for nil:NilClass
from C:/InstantRails-1.3/ruby/lib/ruby/1.8/rexml/source.rb:131:in `initialize'
from C:/InstantRails-1.3/ruby/lib/ruby/1.8/rexml/parsers/baseparser.rb:126:in `stream='
from C:/InstantRails-1.3/ruby/lib/ruby/1.8/rexml/parsers/baseparser.rb:100:in `initialize'
from C:/InstantRails-1.3/ruby/lib/ruby/1.8/rexml/parsers/treeparser.rb:8:in `initialize'
from C:/InstantRails-1.3/ruby/lib/ruby/1.8/rexml/document.rb:178:in `build'
from C:/InstantRails-1.3/ruby/lib/ruby/1.8/rexml/document.rb:45:in `initialize'
[BW] Hmmm.... That didn't see to make things better ;-( So I tried it without passing in the file argument.
[BW] So it definitely looks to me like it's the Document.new that's throwing the error. Any ideas? I sure would appreciate it if you'd try entering these commands on your systems and letting me know if you get any different results. Maybe there's something wrong with my config. I've included the content of "mydoc.xml" below. I put it in the 'public' directory.
------------------ mydoc.xml ---------------------
<inventory title="OmniCorp Store #45x10^3">
<item upc="123456789" stock="12">
<description>Makes you invisible</description>
<item upc="445322344" stock="18">
<description>Levitate yourself for up to 3 hours per application</description>
<item upc="485672034" stock="653">
<name>Blork and Freen Instameal</name>
<description>A tasty meal in a tablet; just add water</description>
<item upc="132957764" stock="44">
<description>Tender winglets of Grob. Just add water</description>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Instantrails-users