How to get builder 2.0 to escape attributes in rxml

I am using rxml to produce opml files and need to escape ampersands in
the attributes.

builder 2.0 docs found at http://builder.rubyforge.org/ show the
following

xml = Builder::XmlMarkup.new
xml.sample(:escaped=>“This&That”, :unescaped=>:“Here&There”)
xml.target! =>

I tried to install and repeat this result, but attributes are not
escaping

Here is the gem install and the attempt to test escaping attributes:

C:\rails>“c:\ruby\bin\ruby.exe” “c:\ruby\bin\gem” install builder
–version 2.0

Attempting local installation of ‘builder’
Local gem file not found: builder*.gem
Attempting remote installation of ‘builder’
Successfully installed builder-2.0.0
Installing RDoc documentation for builder-2.0.0…

C:\rails>cd buildertest

C:\rails\buildertest>ruby script/console
Loading development environment.

xml = Builder::XmlMarkup.new
=>
xml.sample(:escaped=>“this & that”)
=> “<sample escaped="this & that"/>”
exit

Does anybody know what could be wrong?

Alex,
Alex,

Use builder’s << operator to append text without escaping markup.

Example
xml.<< ‘This&That’

See also my blog post on using this in rxml templates:
http://www.depixelate.com/articles/2006/07/18/quick-tip-rails-partials-in-rss-feeds

See also the docs:
http://caboo.se/doc/classes/Builder/XmlBase.html#M004081

Hope this helps,
Zack

Thanks for the reponse Zack, but my problem is the opposite. I need
Builder to escape the markup and it’s not doing it for some reason.

When I use buidler

this is what I get

C:\rails\buildertest>ruby script/console
Loading development environment.

xml = Builder::XmlMarkup.new
=>
xml.sample(:escaped=>“this & that”)
=> “<sample escaped="this & that"/>”
exit

If you look at the markup you can see that what is supposed to be
escaped is not.

I am running builder 2.0 and the specs say that it should escape
attributes, but for some reason it doesn’t seem to be working.

Any idea what might be wrong?

Zack C. wrote:

Alex,
Alex,

Use builder’s << operator to append text without escaping markup.

Example
xml.<< ‘This&That’

See also my blog post on using this in rxml templates:
http://www.depixelate.com/articles/2006/07/18/quick-tip-rails-partials-in-rss-feeds

See also the docs:
http://caboo.se/doc/classes/Builder/XmlBase.html#M004081

Hope this helps,
Zack