To add a CDATA element in Builder use xml.cdata! and nest it within another xml method block e.g.

xml = Builder::XmlMarkup.new( :target => buffer='', :indent => 2 )
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"

xml.result do
xml.summary do
xml.title do
xml.cdata!("Hello world")
end
end
xml.records
end

@content_type = 'text/xml'
buffer


output:




Using CDATA in Builder | DZone Snippets | News





Resources:
- Builder for Markup [rubyforge.org]

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/dQ7NyU-AgDo/11473