Help required in generating xml + sinatra

hello,
this is my sintra code can any one tell why xml isn't been generated on
browser

####### this is my sinatra code############

get '/multiquery.xml' do
  content_type('text/xml')
  array_of_names = params[:name]
  '#{construct_xml(array_of_names)}'
end

the method construct_xml look like this

  def construct_xml(names)
    xml = Builder::XmlMarkup.new(:indent =>1)
    xml.instruct!
    names.each do |name|
        xml.queryresponse {
        xml.name "#{name}"
        xml.credential "Engineer"
      }
    end
    return xml
  end

Now the point is that the method "construct_xml" construct the
appropriate xml
but the the xml doesn't appear in browser
and the line of code '#{construct_xml(array_of_name)}' run into "XML
Parsing Error: not well-formed"

iam sure that xml is formed properly.i mean to say the i have set the
:target => $stdout

like this
Builder::XmlMarkup.new(:target =>$stdout ,:indent =>1)
and the xml is constructed properly in console
ent .Is there any thing that I am missing.

please reply

thanks anyway

···

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

You use single quotes. Those are not interpolated.

If you do "#{construct_xml(array_of_names)}", everything should work.

Regards,
Skade

···

On Sep 9, 2009, at 9:40 AM, Ken Ghosh wrote:

hello,
this is my sintra code can any one tell why xml isn't been generated on
browser

####### this is my sinatra code############

get '/multiquery.xml' do
content_type('text/xml')
array_of_names = params[:name]
'#{construct_xml(array_of_names)}'
end

the method construct_xml look like this

def construct_xml(names)
   xml = Builder::XmlMarkup.new(:indent =>1)
   xml.instruct!
   names.each do |name|
       xml.queryresponse {
       xml.name "#{name}"
       xml.credential "Engineer"
     }
   end
   return xml
end

Now the point is that the method "construct_xml" construct the
appropriate xml
but the the xml doesn't appear in browser
and the line of code '#{construct_xml(array_of_name)}' run into "XML
Parsing Error: not well-formed"

iam sure that xml is formed properly.i mean to say the i have set the
:target => $stdout

like this
Builder::XmlMarkup.new(:target =>$stdout ,:indent =>1)
and the xml is constructed properly in console
ent .Is there any thing that I am missing.

please reply

thanks anyway
--
Posted via http://www.ruby-forum.com/\.

--
Florian Gilcher

smtp: flo@andersground.net
jabber: Skade@jabber.ccc.de
gpg: 533148E2

You use single quotes. Those are not interpolated.

If you do "#{construct_xml(array_of_names)}", everything should work.

Better, don't use quotes for no reason:

   construct_xml(names)

get '/multiquery.xml' do
content_type('text/xml')
array_of_names = params[:name]
'#{construct_xml(array_of_names)}'
end

"array_of_" is equally useless. plural implies a collection.

...

iam sure that xml is formed properly.i mean to say the i have set the
:target => $stdout

like this
Builder::XmlMarkup.new(:target =>$stdout ,:indent =>1)
and the xml is constructed properly in console
ent .Is there any thing that I am missing.

Yes, there is something REALLY OBVIOUS that you're missing. A test.

The SIMPLEST of tests would have made this entire question obvious.

···

On Sep 9, 2009, at 07:44 , Florian Gilcher wrote:

On Sep 9, 2009, at 9:40 AM, Ken Ghosh wrote: