Skip to content

Instantly share code, notes, and snippets.

@HusseinMorsy
Created April 9, 2009 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HusseinMorsy/92246 to your computer and use it in GitHub Desktop.
Save HusseinMorsy/92246 to your computer and use it in GitHub Desktop.
generate xml with builder
require 'rubygems'
require 'builder'
xml = Builder::XmlMarkup.new
xml.instruct!(:xml, :encoding => "UTF-8")
xml.person do |person|
person.firstname("Laura")
person.lastname("Croft",:married=>"No")
end
puts xml.target!
# <?xml version="1.0" encoding="UTF-8"?>
# <person>
# <firstname>Laura</firstname>
# <lastname married="No">Croft</lastname>
# </person>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment