Created
August 4, 2009 15:33
-
-
Save andyjeffries/161306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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