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.
D4b246038154d7cc2363256bd25a4fe0?d=identicon&s=25 Larry White (Guest)
on 2006-06-02 14: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.
23172b6630dc631a134c9bad2fec2a39?d=identicon&s=25 Chris (Guest)
on 2006-06-02 15:29
Larry White 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.