# Question about REXML

**URL:** <https://www.ruby-forum.com/t/question-about-rexml/149055>\
**Category:** Ruby\
**Created:** [September 19, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/question-about-rexml/149055 "2008-09-19T21:18:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [September 19, 2008, 9:18pm UTC](https://www.ruby-forum.com/t/question-about-rexml/149055/1 "2008-09-19T21:18:27Z")

</div>

I’m trying to follow this tutorial:  
[http://www.germane-software.com/software/rexml/docs/tutorial.html](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:  
 … \</\>

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

Why is it failing?

Thank you

Brad

---

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [September 19, 2008, 10:00pm UTC](https://www.ruby-forum.com/t/question-about-rexml/149055/2 "2008-09-19T22:00:43Z")

</div>

Brad [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Why is it failing?

It isn’t. 🙂 Say

puts doc

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

---

<div class="post-metadata">

**Author:** ![brad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/59ef9b/32.png) [@brad](https://www.ruby-forum.com/u/brad)\
**Post date:** [September 20, 2008, 5:19pm UTC](https://www.ruby-forum.com/t/question-about-rexml/149055/3 "2008-09-20T17:19:33Z")

</div>

On 19.09.2008 20:33, Brad wrote:

> 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
