I have question regarding render :text ... I read the conten of XML file and display it using render :text ... but the content only is shown and not the entire xml file ... How do I get the xml file display as xml file in the output? to state with an example the problem I have if the xml is <animal>dog</animal> and I use render :text then output is only dog... I want to output entire <animal>dog</animal> Need help Regards, Sudhindra -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, are you sure that this is real output? Try using wget or curl to see what real output is. Or maybe look into page source? (Ctrl + V on firefox). It might be that your browser is not displaying xml tags just ignoring them, and displays only what''s inside. Best, H On 20 Mar, 15:44, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have question regarding render :text ... I read the conten of XML file > and display it using render :text ... but the content only is shown and > not the entire xml file ... How do I get the xml file display as xml > file in the output? > > to state with an example the problem I have if the xml is > <animal>dog</animal> and I use render :text then output is only dog... I > want to output entire <animal>dog</animal> > > Need help > > Regards, > Sudhindra > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Mar 20, 2009 at 7:44 AM, Sudhi Kulkarni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> to state with an example the problem I have if the xml is > <animal>dog</animal> and I use render :text then output is only dog... I > want to output entire <animal>dog</animal>You need to escape the angle brackets, e.g. <% @xml = "<animal>dog</animal>" %> <%=h @xml %> Try the above with and without the ''h''. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why don''t you use the render :xml?
Rendering XML
Rendering XML sets the content type to application/xml.
# Renders ''<name>David</name>''
render :xml => {:name => "David"}.to_xml
It‘s not necessary to
call<http://api.rubyonrails.org/classes/ActionController/Base.html#M000612>
to_xml on the object you want to
render<http://api.rubyonrails.org/classes/ActionController/Base.html#M000633>,
since
render<http://api.rubyonrails.org/classes/ActionController/Base.html#M000633>will
automatically do that for you:
# Also renders ''<name>David</name>''
render :xml => {:name => "David"}
On Fri, Mar 20, 2009 at 12:07 PM, Hassan Schroeder <
hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> On Fri, Mar 20, 2009 at 7:44 AM, Sudhi Kulkarni
> <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
> > to state with an example the problem I have if the xml is
> > <animal>dog</animal> and I use render :text then output is
only dog... I
> > want to output entire <animal>dog</animal>
>
> You need to escape the angle brackets, e.g.
>
> <% @xml = "<animal>dog</animal>" %>
>
> <%=h @xml %>
>
> Try the above with and without the ''h''.
>
> --
> Hassan Schroeder ------------------------
hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---