Read and parse xml

Hi all,
I need to hit a URL that returns me a xml file,which I should read and
parse.
How could I do it,access the URL,retrieve the content of the response
and process it?

Regards,
Rafael R.

At 2009-09-02 10:28AM, “Rafael R.” wrote:

Hi all,
I need to hit a URL that returns me a xml file,which I should read and
parse.
How could I do it,access the URL,retrieve the content of the response
and process it?

Read about the standard library package “open-uri” to retrieve the URL
contents, and “Nokogiri” (gem) or “Hpricot” (gem) or “REXML” (standard
library package) to process the XML

http://www.ruby-doc.org/stdlib/
http://nokogiri.rubyforge.org/nokogiri/
http://github.com/whymirror/hpricot/tree/master

On Sep 2, 2009, at 7:28 AM, Rafael R. wrote:

Hi all,
I need to hit a URL that returns me a xml file,which I should read and
parse.
How could I do it,access the URL,retrieve the content of the response
and process it?

You can use open-uri for fetching the content. Then you can use
nokogiri for processing the XML response.

Here are some docs that will get you started:

http://nokogiri.org/

Hope that helps.


Aaron P.
http://tenderlovemaking.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs