Loading XML file from web

S

Szymon Rozga

This is pretty much straight from the documentation of Net::HTTP

require 'net/http'
Net::HTTP.start('www.digg.com', 80) { |http|
response = http.get('rss/index.xml')
response.body # this is the text of www.digg.com/rss/index.xml
}

so simply now create an instance of Document with the text
response.body (I haven't tried this out myself, but should work)
 
J

James Britt

Szymon said:
This is pretty much straight from the documentation of Net::HTTP

require 'net/http'
Net::HTTP.start('www.digg.com', 80) { |http|
response = http.get('rss/index.xml')
response.body # this is the text of www.digg.com/rss/index.xml
}

so simply now create an instance of Document with the text
response.body (I haven't tried this out myself, but should work)

Or use open-uri.


http://www.ruby-doc.org/stdlib/libdoc/open-uri/rdoc/


James


--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
K

Kevin Olbrich

How about this....

--
require "open-uri"
open("http://www.digg.com/rss/index.xml") do |file|
file.each_line {|line| puts line}
end
--

This will just dump the contents of the file.
-Kevin


-----Original Message-----
From: Szymon Rozga [mailto:[email protected]]
Sent: Monday, August 08, 2005 11:11 PM
To: ruby-talk ML
Subject: Re: Loading XML file from web


This is pretty much straight from the documentation of Net::HTTP

require 'net/http'
Net::HTTP.start('www.digg.com', 80) { |http|
response = http.get('rss/index.xml')
response.body # this is the text of www.digg.com/rss/index.xml }

so simply now create an instance of Document with the text response.body (I
haven't tried this out myself, but should work)
 
S

Singee15

Thank you, yours was the one which worked. The others caused parsing
errors.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top