saasbook

builder_example.rb

Aug 15th, 2013
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.44 KB | None | 0 0
  1. <person type="faculty">
  2.   <name>Barbara Liskov</name>
  3.   <contact>
  4.     <phone location="office">617-253-2008</phone>
  5.     <email>liskov@csail.mit.edu</email>
  6.   </contact>
  7. </person>
  8.  
  9. # Code that generates the above markup:
  10. require 'builder'
  11. b = Builder::XmlMarkup.new(:indent => 2)
  12. b.person :type => 'faculty' do
  13.   b.name "Barbara Liskov"
  14.   b.contact do
  15.     b.phone "617-253-2008", :location => 'office'
  16.     b.email "liskov@csail.mit.edu"
  17.   end
  18. end
Add Comment
Please, Sign In to add comment