How do i create & insert data into xml file in ruby

hello

How do i create new xml file & insert data into that new xml file in
ror
plz explain with example code.(say i have to insert all the values of a
table into xml file )

advance thx
Have a pleasant day

narayana

Narayana Karthik wrote:

hello

How do i create new xml file & insert data into that new xml file in
ror
plz explain with example code.(say i have to insert all the values of a
table into xml file )

advance thx
Have a pleasant day

narayana

Hi Narayana,

You create an rxml file in one of your views. In that file, you do
something along these lines:

xml.instruct!
#=> <?xml version="1.0" encoding="UTF-8"?>
xml.div( :class=> “leadNotification”) do
xml.timestamp(Time.now)
xml.lead do
xml.lead_number( @lead.id )
xml.first_name( @lead.first_name )

            ...
    end

end

This example is something I used to send an outgoing email in XML
format. Obviously, your example will be a little different but
hopefully this is enough to get you going. I’m pretty sure if you
search google with “XML and RAILS and RXML” then you will find more
complete examples.

Regards,

Michael