Skip to content

Instantly share code, notes, and snippets.

@andyjeffries
Created August 4, 2009 15:33
Show Gist options
  • Save andyjeffries/161306 to your computer and use it in GitHub Desktop.
Save andyjeffries/161306 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'builder'
favorites = {
'candy' => 'Neccos', 'novel' => 'Empire of the Sun', 'holiday' => 'Easter'
}
xml = Builder::XmlMarkup.new(:indent => 2 ) do |b|
b.instruct! :xml, :version => "1.1", :encoding => "UTF-8"
b.favorites do
favorites.each do | name, choice |
b.favorite( choice, :item => name )
end
end
end
puts xml
# Running this command with ruby test_xml.rb gives:
# test_xml.rb:20:in `puts': Builder::XmlMarkup#to_ary should return Array (TypeError)
# from test_xml.rb:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment