%Q is ticket for this kind of thing:

   %Q[<?xml version="1.0" encoding="UTF-8"...#{a}...>]

%Q can use any character following it as a "double-quote" character. It 
knows that some characters (like '[') are left-handed and will use their 
right-handed counterparts (']') to close the quote. (I also considered 
using '|' and '!'.)

Another option is to backquote the interior double-quotes:

   "<?xml version=\"1.0\" encoding=\"UTF-8\"...#{a}...>"

Any questions about testing with Ruby are on-topic for this list.

Bret

At 04:55 PM 9/28/2005, Chris McMahon wrote:
>Hi...
>
>Sorry for the OT post, but this is driving me crazy...
>
>I have an XML string that needs double-quotes, so to turn it into a
>string, I enclose in single quotes.  It looks a little like this:
>
>'<?xml version="1.0" encoding="UTF-8"...>'
>
>But I also need to substitute a variable into the string with #{}, like so:
>
>a = 123
>'<?xml version="1.0" encoding="UTF-8"...#{a}...>'
>
>but #{} doesn't work inside of single-quoted strings, and
>double-quotes inside of double-quotes are illegal, and slashes also
>don't work, i.e
>
>a = 123
>/<?xml version="1.0" encoding="UTF-8"...#{a}...>/
>
>Any suggestions to substitute a string and use double-quotes
>simultaneously in a single string?  I'm sure it's possible, I just
>can't figure out how....
>-Chris
>
>_______________________________________________
>Wtr-general mailing list
>[email protected]
>http://rubyforge.org/mailman/listinfo/wtr-general

_____________________
  Bret Pettichord
  www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to