XML in rails

I have an XML file containing data which I need to access in the
controller. For example, the XML file contains cpu usage and cpu load
and other such information. I need to collect this information into a
controller and display it in a graph (chartdirector). How do I get the
values from the XML file to the controller?

On Mon, Jan 18, 2010 at 8:08 AM, Sujay B. [email protected]
wrote:

I have an XML file containing data which I need to access in the
controller. For example, the XML file contains cpu usage and cpu load
and other such information. I need to collect this information into a
controller and display it in a graph (chartdirector). How do I get the
values from the XML file to the controller?

Open the file and use Nokogiri (gem) to parse the XML.

Did you checkout the nokogiri plugin? Also there is ReXML

Where would you recommend putting all of the parsing code, in a Model
or Controller? I’m very new at working with MVC, but to be it seems
that an XML document, being a representation of data, would be handled
by a Model. Am I wrong? Thanks!

On Jan 18, 11:16Â am, Hassan S. [email protected]

2010/1/18 Seirie [email protected]:

Where would you recommend putting all of the parsing code, in a Model
or Controller? I’m very new at working with MVC, but to be it seems
that an XML document, being a representation of data, would be handled
by a Model. Am I wrong? Thanks!

You are completely correct, put the reading and parsing in a model
that is not derived from AR::base

Colin

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