Forum: Ruby on Rails XML on a external website

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daan (Guest)
on 2006-02-01 17:47
In my rails application i want to fetch an external xml file

So my website www.test.com needs an xml file from
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.
Alex Y. (Guest)
on 2006-02-01 18:15
(Received via mailing list)
Daan wrote:
> In my rails application i want to fetch an external xml file
>
> So my website www.test.com needs an xml file from
> 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"
xml_doc = REXML::Document.new(rio(url))

More info here:
   http://www.germane-software.com/software/rexml/doc...
and here:
   http://rio.rubyforge.org/
Daan (Guest)
on 2006-02-01 22:00
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 needs an xml file from
>> 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"
> xml_doc = REXML::Document.new(rio(url))
>
> More info here:
>    http://www.germane-software.com/software/rexml/doc...
> and here:
>    http://rio.rubyforge.org/
Alex Y. (Guest)
on 2006-02-02 00:46
(Received via mailing list)
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...
This topic is locked and can not be replied to.