XML on a external website


#1

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.


#2

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/docs/tutorial.html
and here:
http://rio.rubyforge.org/


#3

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/docs/tutorial.html
and here:
http://rio.rubyforge.org/


#4

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…