Question about REXML

M

matt neuburg

Brad said:
When I use the IRB and do:
require "rexml/document"
include REXML
doc = Document.new File.new("mydoc.xml")

I get an error:
<UNDEFINED> ... </>

I copied the source file right from the website and created an XML
document called 'mydoc.xml'

Why is it failing?

It isn't. :) Say

puts doc

....and you will see that all is well. m.
 
R

Robert Klemme

I'm trying to follow this tutorial: http://www.germane-software.com/software/rexml/docs/tutorial.html

When I use the IRB and do:
require "rexml/document"
include REXML
doc = Document.new File.new("mydoc.xml")

I get an error:
<UNDEFINED> ... </>

I copied the source file right from the website and created an XML
document called 'mydoc.xml'

Why is it failing?

As Matt said, it isn't. But you should make it a habit to properly
close file handles; use any of these:

doc = Document.new File.read("mydoc.xml")
doc = File.open("mydoc.xml") {|io| Document.new(io)}
doc = File.open("mydoc.xml", "rb") {|io| Document.new(io)}

Kind regards

robert
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top