Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Question about REXML
Brad
9/19/2008 6:33:00 PM
I'm trying to follow this tutorial:
http://www.germane-software.com/software/rexml/docs/tut...
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?
Thank you
Brad
2 Answers
matt
9/19/2008 7:57:00 PM
0
Brad <bradaskins@gmail.com> wrote:
> 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.
--
matt neuburg, phd = matt@tidbits.com,
http://www.tidbits...
Leopard -
http://www.takecontrolbooks.com/leopard-custom...
AppleScript -
http://www.amazon.com/gp/product/...
Read TidBITS! It's free and smart.
http://www.t...
Robert Klemme
9/20/2008 2:42:00 PM
0
On 19.09.2008 20:33, Brad wrote:
> I'm trying to follow this tutorial:
http://www.germane-software.com/software/rexml/docs/tut...
>
> 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
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Question about REXML
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password