Simple example of fetching data from url and then parsing returned XML

11 views
Skip to first unread message

j...@via.net

unread,
May 29, 2015, 1:44:08 PM5/29/15
to rubyonra...@googlegroups.com
I would like to fetch some database info. I have to construct a url with arguments, send it then parse the returned XML.

I quick example would be nice, but if someone could point out how to do the following tasks, I could probable figure it out. 

1) Performng a http 'fetch'

2) Parking XML. There must me a library or gem for this...

Thanks,

Joe

Colin Law

unread,
May 30, 2015, 3:34:16 AM5/30/15
to rubyonra...@googlegroups.com
On 29 May 2015 at 18:44, j...@via.net <j...@via.net> wrote:
> I would like to fetch some database info. I have to construct a url with
> arguments, send it then parse the returned XML.
>
> I quick example would be nice, but if someone could point out how to do the
> following tasks, I could probable figure it out.
>
> 1) Performng a http 'fetch'

Is this to run as a background task or from the command line or from a
user request to a rails app?

>
> 2) Parking XML. There must me a library or gem for this...

I assume you mean parsing :) Have a look at nokigiri. In fact I
believe that will fetch it from a url for you. The answer to question
1 is still important as it is not advisable to run code fetching from
a url in a request from a user. No doubt when you googled for ruby
xml parsers you found others, they may well be perfectly acceptable
but I have not tried any of them.

Colin
Reply all
Reply to author
Forward
0 new messages