# XML on a external website

**URL:** <https://www.ruby-forum.com/t/xml-on-a-external-website/99736>\
**Category:** Rails\
**Created:** [February 1, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/xml-on-a-external-website/99736 "2006-02-01T16:47:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Daan](https://www.ruby-forum.com/u/Daan)\
**Post date:** [February 1, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/xml-on-a-external-website/99736/1 "2006-02-01T16:47:52Z")

</div>

In my rails application i want to fetch an external xml file

So my website [www.test.com](http://www.test.com) needs an xml file from  
[www.example.com/xml.asp?query=hallo](http://www.example.com/xml.asp?query=hallo). In my rails application i want to  
fetch and handle this file as an xml object.

Can anyone help me?

Thanks.

---

<div class="post-metadata">

**Author:** ![Daan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Daan](https://www.ruby-forum.com/u/Daan)\
**Post date:** [February 1, 2006, 5:15pm UTC](https://www.ruby-forum.com/t/xml-on-a-external-website/99736/2 "2006-02-01T17:15:01Z")

</div>

Daan wrote:

> In my rails application i want to fetch an external xml file
> 
> So my website [www.test.com](http://www.test.com) needs an xml file from  
> [www.example.com/xml.asp?query=hallo](http://www.example.com/xml.asp?query=hallo). In my rails application i want to  
> fetch and handle this file as an xml object.

require ‘rio’  
require ‘rexml/document’  
url = “[http://www.example.com/xml.asp?query=hallo](http://www.example.com/xml.asp?query=hallo)”  
xml\_doc = REXML::Document.new(rio(url))

More info here:  
[http://www.germane-software.com/software/rexml/docs/tutorial.html](http://www.germane-software.com/software/rexml/docs/tutorial.html)  
and here:  
[http://rio.rubyforge.org/](http://rio.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![Daan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Daan](https://www.ruby-forum.com/u/Daan)\
**Post date:** [February 1, 2006, 9:00pm UTC](https://www.ruby-forum.com/t/xml-on-a-external-website/99736/3 "2006-02-01T21:00:00Z")

</div>

I get the following error:

RIO::Rio is not a valid input stream. It must be  
either a String, IO, StringIO or Source.

Alex Y. wrote:

> Daan wrote:
> 
> > In my rails application i want to fetch an external xml file
> > 
> > So my website [www.test.com](http://www.test.com) needs an xml file from  
> > [www.example.com/xml.asp?query=hallo](http://www.example.com/xml.asp?query=hallo). In my rails application i want to  
> > fetch and handle this file as an xml object.
> 
> require ‘rio’  
> require ‘rexml/document’  
> url = “[http://www.example.com/xml.asp?query=hallo](http://www.example.com/xml.asp?query=hallo)”  
> xml\_doc = REXML::Document.new(rio(url))
> 
> More info here:  
> [http://www.germane-software.com/software/rexml/docs/tutorial.html](http://www.germane-software.com/software/rexml/docs/tutorial.html)  
> and here:  
> [http://rio.rubyforge.org/](http://rio.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![Daan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Daan](https://www.ruby-forum.com/u/Daan)\
**Post date:** [February 1, 2006, 11:46pm UTC](https://www.ruby-forum.com/t/xml-on-a-external-website/99736/4 "2006-02-01T23:46:33Z")

</div>

Daan wrote:

> I get the following error:
> 
> RIO::Rio is not a valid input stream. It must be  
> either a String, IO, StringIO or Source.

Oops… Should be:

xml\_doc = REXML::Document.new(rio(url).read)

A lot of places, you can just use rio() and it’ll Just Work. Evidently  
not here…
