Escaping quotes for generating xml


#1

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.


#2

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