[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

HTTP requests

Peter Kemp

4/24/2007 3:51:00 AM

Hi all,

Im trying to retrieve an xml document from a website but all i get is
the html

I know their is a way to get this same page via xml

require 'net/http'
require "rexml/document"

url =
'http://jira.atlassian.com/secure/BrowseProjects.jspa?=&os_username=soaptester&os_password=soapt...
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
puts(data)

doc = REXML::Document.new(data)

any help would be great

--
Posted via http://www.ruby-....

9 Answers

John Joyce

4/24/2007 4:45:00 AM

0

Perhaps they're serving xhtml?
then it is xml.
On Apr 24, 2007, at 12:51 PM, Peter Kemp wrote:

> Hi all,
>
> Im trying to retrieve an xml document from a website but all i get is
> the html
>
> I know their is a way to get this same page via xml
>
> require 'net/http'
> require "rexml/document"
>
> url =
> 'http://jira.atlassian.com/secure/BrowseProj...
> =&os_username=soaptester&os_password=soaptester'
> resp = Net::HTTP.get_response(URI.parse(url))
> data = resp.body
> puts(data)
>
> doc = REXML::Document.new(data)
>
> any help would be great
>
> --
> Posted via http://www.ruby-....
>


Peter Kemp

4/24/2007 5:06:00 AM

0

John Joyce wrote:
> Perhaps they're serving xhtml?
> then it is xml.

No idea what that means lol

Kinda new to ruby

--
Posted via http://www.ruby-....

Dan Zwell

4/24/2007 5:09:00 AM

0

Maybe it would serve xml if you sent the request with a header
specifying {'Accept' => 'application/xhtml+xml'} ? But I don't think you
can specify a header with Net::HTTP.get_response(), maybe try using
Net::HTTP#get() ?

Dan

Peter Kemp wrote:
> Hi all,
>
> Im trying to retrieve an xml document from a website but all i get is
> the html
>
> I know their is a way to get this same page via xml
>
> require 'net/http'
> require "rexml/document"
>
> url =
> 'http://jira.atlassian.com/secure/BrowseProjects.jspa?=&os_username=soaptester&os_password=soapt...
> resp = Net::HTTP.get_response(URI.parse(url))
> data = resp.body
> puts(data)
>
> doc = REXML::Document.new(data)
>
> any help would be great
>

Phillip Gawlowski

4/24/2007 5:24:00 AM

0

Peter Kemp wrote:
> John Joyce wrote:
>> Perhaps they're serving xhtml?
>> then it is xml.
>
> No idea what that means lol

http://www.w3schools.com/d...

> Kinda new to ruby

Has nothing to do with Ruby.


--
Phillip "CynicalRyan" Gawlowski
http://cynicalryan....
http://clothred.rub...

Welcome to the real world.
- Morpheus

John Joyce

4/24/2007 5:54:00 AM

0

XML is a markup language with some general but strict rules. Its
actual structure varies widely. iTunes playlists, MS Word document
metadata, and yes xhtml. not old html, but a form of it that is
replacing it and is compliant with xml rules. (more or less)
Most xml files are probably hashes with nested hashes (associative
arrays with nested associative arrays), and they follow the KVC
format, Key=>Value coding. Great for storing data and preferences and
all kinds of things. And easy to change from one format to another.
XML is a pretty simple, but often confusing topic. Most books treat
it as a subject distinct from anything else, but it isn't.
There are some Java and XML books, for example that introduce XML in
a working environment.

Just remember it's structured data, stored as a text file.
Conceptually, not different from YAML, just more strict.
On Apr 24, 2007, at 2:23 PM, Phillip Gawlowski wrote:

> Peter Kemp wrote:
>> John Joyce wrote:
>>> Perhaps they're serving xhtml?
>>> then it is xml.
>> No idea what that means lol
>
> http://www.w3schools.com/d...
>
>> Kinda new to ruby
>
> Has nothing to do with Ruby.
>
>
> --
> Phillip "CynicalRyan" Gawlowski
> http://cynicalryan....
> http://clothred.rub...
>
> Welcome to the real world.
> - Morpheus
>


tuhin

4/24/2007 7:06:00 AM

0

Hi guys,

I have an user registration page. In that page there
are 5 input fields.

I have to save user id and password in "login" table and other 3 input
in "userinfo" table.

Regarding thid tropic I have two questions:

1. How can i retrive the post data from the input field?
2. How can i save data in two table by one model?

I use instants rails 1.4 and mysel 5

please give me some ideas? also waitng for some sample code .

Amin


Robert Dober

4/24/2007 9:46:00 AM

0

On 4/24/07, Md. Ruhul Amin <amin@e-sao.co.jp> wrote:
> Hi guys,
>
> I have an user registration page. In that page there
> are 5 input fields.
>
> I have to save user id and password in "login" table and other 3 input
> in "userinfo" table.
>
> Regarding thid tropic I have two questions:
>
> 1. How can i retrive the post data from the input field?
> 2. How can i save data in two table by one model?
>
> I use instants rails 1.4 and mysel 5
>
> please give me some ideas? also waitng for some sample code .
>
> Amin
>
>
>
Also you might still get some help on this list I strongly advice you
to post this to the rails mailing list.
rubyonrails-talk@googlegroups.com

Cheers
Robert


--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw

Robert Dober

4/24/2007 9:46:00 AM

0

:Also.to_s.sub(/.*/,"although")
Grrrrrrrrrr

Felipe Contreras

4/24/2007 10:26:00 AM

0

On 4/24/07, Peter Kemp <peterkemp@gmail.com> wrote:
> John Joyce wrote:
> > Perhaps they're serving xhtml?
> > then it is xml.
>
> No idea what that means lol
>
> Kinda new to ruby

google: xhtml

But it's not, it's HTML 4.0 Transitional.

Anyway it's not a Ruby issue, you need to find the right URL first.
I'm not sure if you can use the Accept header, that depends on the
site you are accessing.

--
Felipe Contreras