Forum: Ruby on Rails escaping quotes for generating xml

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Larry W. (Guest)
on 2006-06-02 16:41
(Received via mailing list)
Hi,

I need to have my controller return xml from db content.  Is there a
method
I can call to clean up the text for xml rendering?  I tried
CGI:escapeHTML,
but forgot it would ignore quotes.  some of the db content is going in
xml
attributes so the quotes need escaping.


thanks.
Chris (Guest)
on 2006-06-02 17:29
Larry W. wrote:
> Hi,
>
> I need to have my controller return xml from db content.  Is there a
> method
> I can call to clean up the text for xml rendering?  I tried
> CGI:escapeHTML,
> but forgot it would ignore quotes.  some of the db content is going in
> xml
> attributes so the quotes need escaping.
>
>
> thanks.

I just tried this:
irb(main):009:0> a1 = REXML::Attribute.new('x',"y'z'a")
=> x='y'z'a'

Maybe using the REXML module will help?

Cheers
This topic is locked and can not be replied to.